commit d72f832b1ebab0db106e64bc9f59eba90c414311 (tree)
parent 335c680cde670776280c3a812adb64abd1311d97
Author: Andrew Kelley <andrew@ziglang.org>
Date: Thu, 10 Feb 2022 23:03:13 -0700
LLVM backend: call constPtrToInt instead of constBitCast
when appropriate. Avoids tripping an LLVM assertion.
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
@@ -1858,7 +1858,11 @@ pub const DeclGen = struct {
try self.resolveGlobalDecl(decl);
const llvm_type = try self.llvmType(tv.ty);
- return llvm_val.constBitCast(llvm_type);
+ if (tv.ty.zigTypeTag() == .Int) {
+ return llvm_val.constPtrToInt(llvm_type);
+ } else {
+ return llvm_val.constBitCast(llvm_type);
+ }
}
fn lowerPtrToVoid(dg: *DeclGen, ptr_ty: Type) !*const llvm.Value {