From b33f3b23c98d7bb03b116fb084b35ce6b9fc1257 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 3 Mar 2022 01:14:56 -0700 Subject: LLVM: fix lowering of unions and switches `Module.Union.getLayout` now additionally returns a `padding` field which tells how many bytes are between the final field end offset and the ending offset of the union. This is used by the LLVM backend to explicitly insert padding. LLVM backend: lowering of unions now inserts additional padding so that LLVM's internals will agree on the ABI size to match what ABI size zig wants unions to be. This is an alternative to calling LLVMABISizeOfType and LLVMABIAlignmentOfType which end up crashing when recursive struct definitions come into play. We no longer ever call these two functions and the bindings are deleted to avoid future footgun firings. LLVM backend: lowering of unions now represents untagged unions consistently. Before it was tripping an assertion. LLVM backend: switch cases call inttoptr on the case items and condition if necessary. Prevents tripping an LLVM assertion. After this commit, we are no longer tripping over any LLVM assertions. --- src/codegen/llvm/bindings.zig | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/codegen/llvm/bindings.zig') diff --git a/src/codegen/llvm/bindings.zig b/src/codegen/llvm/bindings.zig index a3f7ff9561..fd095ae511 100644 --- a/src/codegen/llvm/bindings.zig +++ b/src/codegen/llvm/bindings.zig @@ -919,12 +919,6 @@ pub const TargetMachine = opaque { pub const TargetData = opaque { pub const dispose = LLVMDisposeTargetData; extern fn LLVMDisposeTargetData(*const TargetData) void; - - pub const ABISizeOfType = LLVMABISizeOfType; - extern fn LLVMABISizeOfType(TD: *const TargetData, Ty: *const Type) c_ulonglong; - - pub const ABIAlignmentOfType = LLVMABIAlignmentOfType; - extern fn LLVMABIAlignmentOfType(TD: *const TargetData, Ty: *const Type) c_uint; }; pub const CodeModel = enum(c_int) { -- cgit v1.2.3