authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-03-12 12:33:32+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-03-12 12:33:32+02:00
log487ee79ec92a69832293d10b16beb4c8471af7ac
treef6ff4b32804b2f1dc2e2479fc35c2c0804c0c9ad
parenta3cfb15fb4be719fe11f231113020532ad0b1258

stage2 llvm: do not use getIntrinsic for airFrameAddress

getIntrinsic gets the return type wrong so we have to add the function manually

2 files changed, 8 insertions(+), 2 deletions(-)

lib/std/debug.zig-1
...@@ -1630,7 +1630,6 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {...@@ -1630,7 +1630,6 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {
1630 .symbol_name = nosuspend di.getSymbolName(address) orelse "???",1630 .symbol_name = nosuspend di.getSymbolName(address) orelse "???",
1631 .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name) catch |err| switch (err) {1631 .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name) catch |err| switch (err) {
1632 error.MissingDebugInfo, error.InvalidDebugInfo => "???",1632 error.MissingDebugInfo, error.InvalidDebugInfo => "???",
1633 else => return err,
1634 },1633 },
1635 .line_info = nosuspend di.getLineNumberInfo(compile_unit.*, address) catch |err| switch (err) {1634 .line_info = nosuspend di.getLineNumberInfo(compile_unit.*, address) catch |err| switch (err) {
1636 error.MissingDebugInfo, error.InvalidDebugInfo => null,1635 error.MissingDebugInfo, error.InvalidDebugInfo => null,
src/codegen/llvm.zig+8-1
...@@ -5347,7 +5347,14 @@ pub const FuncGen = struct {...@@ -5347,7 +5347,14 @@ pub const FuncGen = struct {
5347 if (self.liveness.isUnused(inst)) return null;5347 if (self.liveness.isUnused(inst)) return null;
53485348
5349 const llvm_i32 = self.context.intType(32);5349 const llvm_i32 = self.context.intType(32);
5350 const llvm_fn = self.getIntrinsic("llvm.frameaddress", &.{llvm_i32});5350 const llvm_fn_name = "llvm.frameaddress.p0i8";
5351 const llvm_fn = self.dg.object.llvm_module.getNamedFunction(llvm_fn_name) orelse blk: {
5352 const llvm_p0i8 = self.context.intType(8).pointerType(0);
5353 const param_types = [_]*const llvm.Type{llvm_i32};
5354 const fn_type = llvm.functionType(llvm_p0i8, &param_types, param_types.len, .False);
5355 break :blk self.dg.object.llvm_module.addFunction(llvm_fn_name, fn_type);
5356 };
5357
5351 const params = [_]*const llvm.Value{llvm_i32.constNull()};5358 const params = [_]*const llvm.Value{llvm_i32.constNull()};
5352 const ptr_val = self.builder.buildCall(llvm_fn, &params, params.len, .Fast, .Auto, "");5359 const ptr_val = self.builder.buildCall(llvm_fn, &params, params.len, .Fast, .Auto, "");
5353 const llvm_usize = try self.dg.llvmType(Type.usize);5360 const llvm_usize = try self.dg.llvmType(Type.usize);