commit 487ee79ec92a69832293d10b16beb4c8471af7ac (tree)
parent a3cfb15fb4be719fe11f231113020532ad0b1258
Author: Veikka Tuominen <git@vexu.eu>
Date: Sat, 12 Mar 2022 12:33:32 +0200
stage2 llvm: do not use getIntrinsic for airFrameAddress
getIntrinsic gets the return type wrong so we have to add the function manually
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
@@ -1630,7 +1630,6 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {
.symbol_name = nosuspend di.getSymbolName(address) orelse "???",
.compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name) catch |err| switch (err) {
error.MissingDebugInfo, error.InvalidDebugInfo => "???",
- else => return err,
},
.line_info = nosuspend di.getLineNumberInfo(compile_unit.*, address) catch |err| switch (err) {
error.MissingDebugInfo, error.InvalidDebugInfo => null,
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
@@ -5347,7 +5347,14 @@ pub const FuncGen = struct {
if (self.liveness.isUnused(inst)) return null;
const llvm_i32 = self.context.intType(32);
- const llvm_fn = self.getIntrinsic("llvm.frameaddress", &.{llvm_i32});
+ const llvm_fn_name = "llvm.frameaddress.p0i8";
+ const llvm_fn = self.dg.object.llvm_module.getNamedFunction(llvm_fn_name) orelse blk: {
+ const llvm_p0i8 = self.context.intType(8).pointerType(0);
+ const param_types = [_]*const llvm.Type{llvm_i32};
+ const fn_type = llvm.functionType(llvm_p0i8, ¶m_types, param_types.len, .False);
+ break :blk self.dg.object.llvm_module.addFunction(llvm_fn_name, fn_type);
+ };
+
const params = [_]*const llvm.Value{llvm_i32.constNull()};
const ptr_val = self.builder.buildCall(llvm_fn, ¶ms, params.len, .Fast, .Auto, "");
const llvm_usize = try self.dg.llvmType(Type.usize);