aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-12-28 01:52:19 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-12-28 01:53:58 -0700
commit4b9b9e725777a8f9e4ea9391beaeea34c834615f (patch)
treef1cbd788134cdbcde7f90dc2b9ada91dcd9159ba /src/Compilation.zig
parent232f8a291d2debd8a0fe9df2ce36d9035a15aefb (diff)
downloadzig-4b9b9e725777a8f9e4ea9391beaeea34c834615f.tar.gz
zig-4b9b9e725777a8f9e4ea9391beaeea34c834615f.zip
stage2: LLVM backend: fix lowering of union constants
Comment from this commit reproduced here: LLVM does not allow us to change the type of globals. So we must create a new global with the correct type, copy all its attributes, and then update all references to point to the new global, delete the original, and rename the new one to the old one's name. This is necessary because LLVM does not support const bitcasting a struct with padding bytes, which is needed to lower a const union value to LLVM, when a field other than the most-aligned is active. Instead, we must lower to an unnamed struct, and pointer cast at usage sites of the global. Such an unnamed struct is the cause of the global type mismatch, because we don't have the LLVM type until the *value* is created, whereas the global needs to be created based on the type alone, because lowering the value may reference the global as a pointer.
Diffstat (limited to 'src/Compilation.zig')
0 files changed, 0 insertions, 0 deletions