diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-08 13:01:58 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-08 14:58:53 -0700 |
| commit | 1046ead0cc409287b88554a90c2f80718e1af46d (patch) | |
| tree | eac81f83fe2955c0107e1cda684b1a2abc39b6d3 /src/codegen/llvm.zig | |
| parent | 7cea8f063f710d5fb2fb10723c3e6485b3e2b31d (diff) | |
| download | zig-1046ead0cc409287b88554a90c2f80718e1af46d.tar.gz zig-1046ead0cc409287b88554a90c2f80718e1af46d.zip | |
LLVM: no longer store args into alloca instructions
Previously, we did this so that we could insert a debug variable
declaration intrinsic on the alloca. But there is a dbg.value intrinsic
for declaring variables that are values.
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index ee1cdd6141..2466eea8a9 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -5117,16 +5117,6 @@ pub const FuncGen = struct { self.arg_index += 1; const inst_ty = self.air.typeOfIndex(inst); - const result: struct { ptr: *const llvm.Value, operand: *const llvm.Value } = r: { - if (isByRef(inst_ty)) { - break :r .{ .ptr = arg_val, .operand = arg_val }; - } else { - const ptr_val = self.buildAlloca(try self.dg.llvmType(inst_ty)); - _ = self.builder.buildStore(arg_val, ptr_val); - break :r .{ .ptr = ptr_val, .operand = arg_val }; - } - }; - if (self.dg.object.di_builder) |dib| { const src_index = self.getSrcArgIndex(self.arg_index - 1); const func = self.dg.decl.getFunction().?; @@ -5145,10 +5135,14 @@ pub const FuncGen = struct { const debug_loc = llvm.getDebugLoc(lbrace_line, lbrace_col, self.di_scope.?); const insert_block = self.builder.getInsertBlock(); - _ = dib.insertDeclareAtEnd(result.ptr, di_local_var, debug_loc, insert_block); + if (isByRef(inst_ty)) { + _ = dib.insertDeclareAtEnd(arg_val, di_local_var, debug_loc, insert_block); + } else { + _ = dib.insertDbgValueIntrinsicAtEnd(arg_val, di_local_var, debug_loc, insert_block); + } } - return result.operand; + return arg_val; } fn getSrcArgIndex(self: *FuncGen, runtime_index: u32) u32 { |
