From 125b453c58b6d94a628c94d46e5038e06183c54c Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Fri, 28 Jul 2023 12:48:01 -0400 Subject: llvm: fix SysV C abi for structs smaller than two eightbytes Closes #16038 Closes #16288 --- src/codegen/llvm/Builder.zig | 4 +++- src/codegen/llvm/bindings.zig | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src/codegen/llvm') diff --git a/src/codegen/llvm/Builder.zig b/src/codegen/llvm/Builder.zig index 3e6cf31d69..cd7a0045aa 100644 --- a/src/codegen/llvm/Builder.zig +++ b/src/codegen/llvm/Builder.zig @@ -572,7 +572,9 @@ pub const Type = enum(u32) { pub fn isSized(self: Type, builder: *const Builder) Allocator.Error!bool { var visited: IsSizedVisited = .{}; - return self.isSizedVisited(&visited, builder); + const result = try self.isSizedVisited(&visited, builder); + if (builder.useLibLlvm()) assert(result == self.toLlvm(builder).isSized().toBool()); + return result; } const FormatData = struct { diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index aee9cea384..2fab61d1cf 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -434,6 +434,9 @@ pub const Type = opaque { Packed: Bool, ) void; + pub const isSized = LLVMTypeIsSized; + extern fn LLVMTypeIsSized(Ty: *Type) Bool; + pub const constGEP = LLVMConstGEP2; extern fn LLVMConstGEP2( Ty: *Type, -- cgit v1.2.3