aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-06-08 20:40:16 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-06-08 20:40:16 -0700
commitf4d5fcde727d93da9ebe17a27cc62270545ccda6 (patch)
tree1bb04bf9a99acb6619fae6f2d550672c1249e55c /src/codegen/llvm.zig
parent7c0614ea659b3f404f9d702c990afcac5f0b1479 (diff)
downloadzig-f4d5fcde727d93da9ebe17a27cc62270545ccda6.tar.gz
zig-f4d5fcde727d93da9ebe17a27cc62270545ccda6.zip
AstGen: avoid redundant "ref" instructions
Whenever a `ref` instruction is needed, it is created and saved in `AstGen.ref_table` instead of being immediately appended to the current block body. Then, when the referenced instruction is being added to the parent block (e.g. from setBlockBody), if it has a ref_table entry, then the ref instruction is added directly after the instruction being referenced. This makes sure two properties are upheld: 1. All pointers to the same locals return the same address. This is required to be compliant with the language specification. 2. `ref` instructions will dominate their uses. This is a required property of ZIR. A complication arises when a ref instruction refs another ref instruction. The logic in appendBodyWithFixups must take this into account, recursively handling ref refs.
Diffstat (limited to 'src/codegen/llvm.zig')
0 files changed, 0 insertions, 0 deletions