aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/pointers.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-04 17:19:36 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-03-04 18:27:46 -0700
commitf2a5d0bf94897554e25e889dc1c6c4c7fc6c1217 (patch)
tree0847593f0683a3605f72b2ada866b56c1eb1357c /test/behavior/pointers.zig
parentd3648cc0305ee94e24dd4378376e204587bc6f51 (diff)
downloadzig-f2a5d0bf94897554e25e889dc1c6c4c7fc6c1217.tar.gz
zig-f2a5d0bf94897554e25e889dc1c6c4c7fc6c1217.zip
stage2: fix tuple assigned to variable
Before this we would see ZIR code like this: ``` %69 = alloc_inferred_mut() %70 = array_base_ptr(%69) %71 = elem_ptr_imm(%70, 0) ``` This would crash the compiler because it expects to see a `coerce_result_ptr` instruction after `alloc_inferred_mut`, but that does not happen in this case because there is no type to coerce the result pointer to. In this commit I modified AstGen so that it has similar codegen as when using a const instead of a var: ``` %69 = alloc_inferred_mut() %76 = array_init_anon(.{%71, %73, %75}) %77 = store_to_inferred_ptr(%69, %76) ``` This does not obey result locations, meaning if you call a function inside the initializer, it will end up doing a copy into the LHS. Solving this problem, or changing the language to make this legal, will be left for my future self to deal with. Hi future self! I see you reading this commit log. Hope you're doing OK buddy. Sema for `store_ptr` of a tuple where the pointer is in fact the same element type as the operand had an issue where the comptime fields would get incorrectly lowered to runtime stores to bogus addresses. This is solved with an exception to the optimization in Sema for storing pointers that handles tuples element-wise. In the case that we are storing a tuple to itself, it skips the optimization. This results in better code and avoids the problem. However this caused a regression in GeneralPurposeAllocator from the standard library. I regressed the test runner code back to the simpler path. It's too hard to debug standard library code in the LLVM backend right now since we don't have debug info hooked up. Also, we didn't have any behavior test coverage of whatever was regressed, so let's try to get that coverage added as a stepping stone to getting the standard library working.
Diffstat (limited to 'test/behavior/pointers.zig')
0 files changed, 0 insertions, 0 deletions