Propagate Carbon type alignments into LLVM IR. (#7290)

Use the Carbon-computed alignment for allocas, loads, stores, and
memcpys. Previously we used whatever LLVM felt like giving us, which
would result in ABI mismatches and runtime crashes due to misalignment
when creating objects of imported C++ class types, as well as resulting
in some surprising choices like `(i32, i32)` and `()` having 8-byte
alignment instead of 4 and 1, respectively.
This commit is contained in:
Richard Smith
2026-06-02 01:35:03 +00:00
committed by GitHub
parent 2952f61095
commit b7f11e4c61
74 changed files with 504 additions and 222 deletions
@@ -59,8 +59,8 @@ fn M() {
// CHECK:STDOUT: %m.var = alloca double, align 8, !dbg !15
// CHECK:STDOUT: %ptr_i32.var = alloca ptr, align 8, !dbg !16
// CHECK:STDOUT: %ptr_f64.var = alloca ptr, align 8, !dbg !17
// CHECK:STDOUT: %c.var = alloca {}, align 8, !dbg !18
// CHECK:STDOUT: %.loc40_9.2.temp = alloca {}, align 8, !dbg !19
// CHECK:STDOUT: %c.var = alloca {}, align 1, !dbg !18
// CHECK:STDOUT: %.loc40_9.2.temp = alloca {}, align 1, !dbg !19
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %n.var), !dbg !14
// CHECK:STDOUT: store i32 0, ptr %n.var, align 4, !dbg !14
// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %m.var), !dbg !15