Jacob Young
a702af062b
x86_64: fix InternPool regressions
2023-06-10 20:47:56 -07:00
Jacob Young
4f70863a55
InternPool: fix various pointer issues
2023-06-10 20:47:56 -07:00
Jacob Young
3269256965
behavior: fix more compiler crashes
2023-06-10 20:47:56 -07:00
Jacob Young
3064d2aa7b
behavior: additional llvm fixes
2023-06-10 20:47:56 -07:00
Jacob Young
3b6ca1d35b
Module: move memoized data to the intern pool
...
This avoids memory management bugs with the previous implementation.
2023-06-10 20:47:56 -07:00
Jacob Young
d40b83de45
behavior: pass more tests on llvm again
2023-06-10 20:47:56 -07:00
Jacob Young
2d5bc01469
behavior: get more test cases passing with llvm
2023-06-10 20:47:56 -07:00
Andrew Kelley
c8b0d4d149
InternPool: optimize zigTypeTag()
...
This is a particularly hot function, so we operate directly on encodings
rather than the more straightforward implementation of calling
`indexToKey`.
I measured this as 1.05 ± 0.04 times faster than the previous commit
with a ReleaseFast build against hello world (which includes std.debug
and formatted printing).
I also profiled the function and found that zigTypeTag() went from being
a major caller of `indexToKey` to being completely insignificant due to
being so fast.
2023-06-10 20:47:56 -07:00
Andrew Kelley
fc358435cb
C backend: InternPool fixes
2023-06-10 20:47:56 -07:00
Andrew Kelley
a596ea683c
CLI: introduce --verbose-intern-pool
...
and stop dumping to stderr without the user's consent.
2023-06-10 20:47:56 -07:00
Andrew Kelley
8011faa004
compiler: fix populateTestFunctions InternPool usage
2023-06-10 20:47:56 -07:00
Andrew Kelley
270f9e24dd
AstGen: generate tests with anyerror!void
...
rather than inferred error sets. This avoids extra unnecessary work for
the compiler since inferred error sets are unique types.
2023-06-10 20:47:56 -07:00
Andrew Kelley
e156c1c07e
InternPool: correct the logic for struct size dump
2023-06-10 20:47:56 -07:00
Jacob Young
1dc01f1140
InternPool: fix build-exe and compiler-rt crashes
2023-06-10 20:47:55 -07:00
Jacob Young
9cd0ca9f48
Module: rename functions to make ownership checks explicit
...
This makes the difference between `decl.getOwnedFunction` and
`decl.val.getFunction` more clear when reading the code.
2023-06-10 20:47:55 -07:00
Andrew Kelley
d5f0ee0d62
codegen: fix lowering of constant structs
2023-06-10 20:47:55 -07:00
Andrew Kelley
ace5a5e3cc
llvm: simplify control flow lowering structs
2023-06-10 20:47:55 -07:00
Andrew Kelley
63dc0447fc
wasm: fix error union constant lowering
2023-06-10 20:47:55 -07:00
Jacob Young
abded5cbb0
TypedValue: implement more prints
2023-06-10 20:47:55 -07:00
Jacob Young
f2c716187c
InternPool: fix more crashes
2023-06-10 20:47:55 -07:00
Andrew Kelley
66c4396854
AIR: eliminate the values array
2023-06-10 20:47:55 -07:00
Jacob Young
9afa974183
InternPool: fix enough crashes to run build-obj on a simple program
2023-06-10 20:47:55 -07:00
Jacob Young
9a738c0be5
Module: intern the values of decls when they are marked alive
...
I'm not sure if this is the right place for this to happen, and
it should become obsolete when comptime mutation is rewritten
and the remaining legacy value tags are remove, so keeping this
as a separate revertable commit.
2023-06-10 20:47:55 -07:00
Andrew Kelley
f37c0a4593
Sema: inferred allocations no longer abuse type/value system
...
Previously, there were types and values for inferred allocations and a
lot of special-case handling. Now, instead, the special casing is
limited to AIR instructions for these use cases.
Instead of storing data in Value payloads, the data is now stored in AIR
instruction data as well as the previously `void` value type of the
`unresolved_inferred_allocs` hash map.
2023-06-10 20:47:55 -07:00
Jacob Young
5d0d5893fd
Sema: fix some issues with the inferred alloc tag change
2023-06-10 20:47:55 -07:00
Jacob Young
70cc68e999
Air: remove constant tag
...
Some uses have been moved to their own tag, the rest use interned.
Also, finish porting comptime mutation to be more InternPool aware.
2023-06-10 20:47:55 -07:00
Jacob Young
72e4ea3821
InternPool: fix crashes up to in progress comptime mutation
2023-06-10 20:47:55 -07:00
Jacob Young
1a4626d2cf
InternPool: remove more legacy values
...
Reinstate some tags that will be needed for comptime init.
2023-06-10 20:47:54 -07:00
Jacob Young
6e0de1d116
InternPool: port most of value tags
2023-06-10 20:47:54 -07:00
Andrew Kelley
5555bdca04
InternPool: support int->comptime_int in getCoerced
2023-06-10 20:47:54 -07:00
Andrew Kelley
2052260039
Sema: update zirSliceLength to avoid resolveInst(.none)
2023-06-10 20:47:54 -07:00
Andrew Kelley
01ca841f12
Sema: improve the types_to_resolve mechanism
...
Store `InternPool.Index` as the key instead which means that an AIR
instruction no longer needs to be burned to store the type, and also
that we can use AutoArrayHashMap instead of an ArrayList, which avoids
storing duplicates into the set, potentially saving CPU time.
2023-06-10 20:47:54 -07:00
Andrew Kelley
1b64eed107
remove the kludges from std.builtin
...
I added these in an earlier commit in this branch. This commit removes
them before the branch is merged.
2023-06-10 20:47:54 -07:00
Jacob Young
484c3e8cbc
llvm: fix incorrect slice lowering
2023-06-10 20:47:54 -07:00
Jacob Young
a7c3ca3531
InternPool: add lldb pretty printing for indices
2023-06-10 20:47:54 -07:00
Jacob Young
a6fcf469fc
Value: remove legacy type values
2023-06-10 20:47:54 -07:00
Jacob Young
84099e50fc
TypedValue: fix debug print crashes
2023-06-10 20:47:54 -07:00
Jacob Young
be1b231206
InternPool: add missing logic
2023-06-10 20:47:54 -07:00
Jacob Young
9584feae5f
InternPool: fix logic bugs
2023-06-10 20:47:54 -07:00
Jacob Young
dfd91abfe1
InternPool: add more pointer values
2023-06-10 20:47:54 -07:00
Jacob Young
cbf304d8c3
InternPool: fix coersion issues
2023-06-10 20:47:54 -07:00
Jacob Young
25cd4bb3c9
Type: hack around isNoReturn queries for the remaining legacy tags
2023-06-10 20:47:54 -07:00
Andrew Kelley
e4d498cd3a
InternPool: add missing ensureCapacity call with enums
2023-06-10 20:47:54 -07:00
Andrew Kelley
7e19c95668
Sema: move inferred_alloc_const/mut_type to InternPool
...
Now, all types are migrated to use `InternPool`. The `Type.Tag` enum is
deleted in this commit.
2023-06-10 20:47:54 -07:00
Andrew Kelley
65d65f5dda
Module: remove tmp_hack_arena
...
This was only needed when pointers were not fully migrated to InternPool
yet.
2023-06-10 20:47:53 -07:00
Andrew Kelley
dfb3521160
compiler: remove var_args_param_type from SimpleType
...
This is now represented instead by a special `InternPool.Index.Tag` that
has no corresponding type/value.
2023-06-10 20:47:53 -07:00
Jacob Young
115c089562
Value: add intern and unintern to facilitate code conversion
...
This allows some code (like struct initializers) to use interned types
while other code (such as comptime mutation) continues to use legacy
types.
With these changes, an `zig build-obj empty.zig` gets to a crash on
missing interned error union types.
2023-06-10 20:47:53 -07:00
Jacob Young
be78a12d7d
Sema: port Value.decl_ptr to InternPool
2023-06-10 20:47:53 -07:00
Jacob Young
c473594114
Sema: port reify struct access to use InternPool
2023-06-10 20:47:53 -07:00
Jacob Young
f8b6eb63d5
Sema: add coerceTupleToStruct result to the InternPool
2023-06-10 20:47:53 -07:00