aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-14 19:30:56 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-07-14 22:26:11 -0700
commit070e3ea37dd51c2a2080941a056c455f70232148 (patch)
tree9c04d0ad2849ab14550603f19ab49118dbf3bc47 /src/codegen/llvm.zig
parent4c7fe74b2c0e8279d0003f820a18d59e1237b74a (diff)
downloadzig-070e3ea37dd51c2a2080941a056c455f70232148.tar.gz
zig-070e3ea37dd51c2a2080941a056c455f70232148.zip
LLVM: insert debug logging when LLVM ABI size is wrong
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index fe35620d38..714ac16c54 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -2424,6 +2424,24 @@ pub const DeclGen = struct {
}
fn lowerType(dg: *DeclGen, t: Type) Allocator.Error!*const llvm.Type {
+ const llvm_ty = try lowerTypeInner(dg, t);
+ if (std.debug.runtime_safety) {
+ if (t.zigTypeTag() != .Opaque and t.hasRuntimeBits() and
+ !llvm_ty.isOpaqueStruct().toBool())
+ {
+ const zig_size = t.abiSize(dg.module.getTarget());
+ const llvm_size = dg.object.target_data.abiSizeOfType(llvm_ty);
+ if (llvm_size != zig_size) {
+ log.err("when lowering {}, Zig ABI size = {d} but LLVM ABI size = {d}", .{
+ t.fmt(dg.module), zig_size, llvm_size,
+ });
+ }
+ }
+ }
+ return llvm_ty;
+ }
+
+ fn lowerTypeInner(dg: *DeclGen, t: Type) Allocator.Error!*const llvm.Type {
const gpa = dg.gpa;
const target = dg.module.getTarget();
switch (t.zigTypeTag()) {