28 changes: 6 additions & 22 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5622,6 +5622,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
MachineFunction &MF = DAG.getMachineFunction();
const TargetInstrInfo *TII = DAG.getSubtarget().getInstrInfo();

bool IsIndirect = false;
Optional<MachineOperand> Op;
// Some arguments' frame index is recorded during argument lowering.
int FI = FuncInfo.getArgumentFrameIndex(Arg);
Expand All @@ -5643,6 +5644,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
}
if (Reg) {
Op = MachineOperand::CreateReg(Reg, false);
IsIndirect = IsDbgDeclare;
}
}

Expand Down Expand Up @@ -5691,7 +5693,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
}
assert(!IsDbgDeclare && "DbgDeclare operand is not in memory?");
FuncInfo.ArgDbgValues.push_back(
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), false,
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), IsDbgDeclare,
RegAndSize.first, Variable, *FragmentExpr));
}
};
Expand All @@ -5709,6 +5711,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
}

Op = MachineOperand::CreateReg(VMI->second, false);
IsIndirect = IsDbgDeclare;
} else if (ArgRegsAndSizes.size() > 1) {
// This was split due to the calling convention, and no virtual register
// mapping exists for the value.
Expand All @@ -5722,28 +5725,9 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(

assert(Variable->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");

// If the argument arrives in a stack slot, then what the IR thought was a
// normal Value is actually in memory, and we must add a deref to load it.
if (Op->isFI()) {
int FI = Op->getIndex();
unsigned Size = DAG.getMachineFunction().getFrameInfo().getObjectSize(FI);
if (Expr->isImplicit()) {
SmallVector<uint64_t, 2> Ops = {dwarf::DW_OP_deref_size, Size};
Expr = DIExpression::prependOpcodes(Expr, Ops);
} else {
Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
}
}

// If this location was specified with a dbg.declare, then it and its
// expression calculate the address of the variable. Append a deref to
// force it to be a memory location.
if (IsDbgDeclare)
Expr = DIExpression::append(Expr, {dwarf::DW_OP_deref});

IsIndirect = (Op->isReg()) ? IsIndirect : true;
FuncInfo.ArgDbgValues.push_back(
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), false,
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), IsIndirect,
*Op, Variable, Expr));

return true;
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/AArch64/GlobalISel/debug-cpp.ll
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ target triple = "aarch64-unknown-linux-gnu"
%struct.NTCopy = type { i32 }

; CHECK-LABEL: name: _Z3foo6NTCopy
; CHECK: DBG_VALUE %{{[0-9]+}}(p0), $noreg, !23, !DIExpression(DW_OP_deref), debug-location !24
; CHECK: DBG_VALUE %{{[0-9]+}}(p0), 0, !23, !DIExpression(), debug-location !24
; Function Attrs: noinline nounwind optnone
define dso_local i32 @_Z3foo6NTCopy(%struct.NTCopy* %o) #0 !dbg !7 {
entry:
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ entry:
}

; CHECK-LABEL: name: debug_declare_vla
; CHECK: DBG_VALUE %{{[0-9]+}}(p0), $noreg, !14, !DIExpression(DW_OP_deref), debug-location !15
; CHECK: DBG_VALUE %{{[0-9]+}}(p0), 0, !14, !DIExpression(), debug-location !15
define void @debug_declare_vla(i32 %in) #0 !dbg !13 {
entry:
%vla.addr = alloca i32, i32 %in
Expand All @@ -32,11 +32,11 @@ define void @debug_value(i32 %in) #0 !dbg !16 {
store i32 %in, i32* %addr
; CHECK: DBG_VALUE %1(p0), $noreg, !17, !DIExpression(DW_OP_deref), debug-location !18
call void @llvm.dbg.value(metadata i32* %addr, i64 0, metadata !17, metadata !DIExpression(DW_OP_deref)), !dbg !18
; CHECK: DBG_VALUE 123, $noreg, !17, !DIExpression(), debug-location !18
; CHECK: DBG_VALUE 123, 0, !17, !DIExpression(), debug-location !18
call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !17, metadata !DIExpression()), !dbg !18
; CHECK: DBG_VALUE float 1.000000e+00, $noreg, !17, !DIExpression(), debug-location !18
; CHECK: DBG_VALUE float 1.000000e+00, 0, !17, !DIExpression(), debug-location !18
call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !17, metadata !DIExpression()), !dbg !18
; CHECK: DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18
; CHECK: DBG_VALUE $noreg, 0, !17, !DIExpression(), debug-location !18
call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !17, metadata !DIExpression()), !dbg !18
ret void
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM/debug-info-arg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define void @foo(%struct.tag_s* nocapture %this, %struct.tag_s* %c, i64 %x, i64
tail call void @llvm.dbg.value(metadata %struct.tag_s* %c, metadata !13, metadata !DIExpression()), !dbg !21
tail call void @llvm.dbg.value(metadata i64 %x, metadata !14, metadata !DIExpression()), !dbg !22
tail call void @llvm.dbg.value(metadata i64 %y, metadata !17, metadata !DIExpression()), !dbg !23
;CHECK: @DEBUG_VALUE: foo:y <- [DW_OP_plus_uconst 8, DW_OP_deref] $r7
;CHECK: @DEBUG_VALUE: foo:y <- [DW_OP_plus_uconst 8] [$r7+0]
tail call void @llvm.dbg.value(metadata %struct.tag_s* %ptr1, metadata !18, metadata !DIExpression()), !dbg !24
tail call void @llvm.dbg.value(metadata %struct.tag_s* %ptr2, metadata !19, metadata !DIExpression()), !dbg !25
%1 = icmp eq %struct.tag_s* %c, null, !dbg !26
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/PowerPC/debuginfo-stackarg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define i64 @foo(i64 %bar1, i64 %bar2, i64 %bar3, i64 %bar4, i64 %bar5) local_unn
; We expect to find a DBG_VALUE refering to the metadata id for bar5, using the lowest
; of the two fixed stack offsets found earlier.
; CHECK-LABEL: body:
; CHECK: DBG_VALUE $r1, $noreg, !17, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref)
; CHECK: DBG_VALUE $r1, 0, !17, !DIExpression(DW_OP_plus_uconst, 8)
entry:
tail call void @llvm.dbg.value(metadata i64 %bar1, metadata !13, metadata !DIExpression()), !dbg !18
tail call void @llvm.dbg.value(metadata i64 %bar2, metadata !14, metadata !DIExpression()), !dbg !19
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/CodeGen/X86/dbg-value-func-arg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ target triple = "i386-unknown-unknown"

; Function Attrs: norecurse nounwind readnone
define dso_local %struct.bar* @func1(%struct.bar* readnone returned %0, i32 %1, i32 %2, i32* nocapture readnone %3) local_unnamed_addr #0 !dbg !8 {
; CHECK-DAG: DBG_VALUE %fixed-stack.1, $noreg, {{.*}}, !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 0, 32),
; CHECK-DAG: DBG_VALUE %fixed-stack.0, $noreg, {{.*}}, !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 32, 32),
; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, !DIExpression(DW_OP_deref),
; CHECK-DAG: DBG_VALUE %fixed-stack.2, $noreg, {{.*}}, !DIExpression(DW_OP_deref),
; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, !DIExpression(DW_OP_deref_size, 4, DW_OP_plus_uconst, 144, DW_OP_stack_value),
; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, !DIExpression(DW_OP_deref_size, 4, DW_OP_plus_uconst, 144, DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32),
; CHECK-DAG: DBG_VALUE %fixed-stack.1, 0, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32),
; CHECK-DAG: DBG_VALUE %fixed-stack.0, 0, {{.*}}, !DIExpression(DW_OP_LLVM_fragment, 32, 32),
; CHECK-DAG: DBG_VALUE %fixed-stack.3, 0, {{.*}}, !DIExpression(),
; CHECK-DAG: DBG_VALUE %fixed-stack.2, 0, {{.*}}, !DIExpression(),
; CHECK-DAG: DBG_VALUE %fixed-stack.3, 0, {{.*}}, !DIExpression(DW_OP_plus_uconst, 144, DW_OP_stack_value),
; CHECK-DAG: DBG_VALUE %fixed-stack.3, 0, {{.*}}, !DIExpression(DW_OP_plus_uconst, 144, DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32),

call void @llvm.dbg.value(metadata i32 %2, metadata !24, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !26
call void @llvm.dbg.value(metadata i32* %3, metadata !24, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg !26
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/ARM/PR16736.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; RUN: llc -filetype=obj < %s \
; RUN: | llvm-dwarfdump -debug-info - | FileCheck %s --check-prefix=DWARF
;
; CHECK: @DEBUG_VALUE: h:x <- [DW_OP_plus_uconst {{.*}}, DW_OP_deref] $r{{.*}}
; CHECK: @DEBUG_VALUE: h:x <- [DW_OP_plus_uconst {{.*}}] [$r{{.*}}+0]
; DWARF: DW_TAG_formal_parameter
; DWARF: DW_AT_location
; DWARF-NEXT: DW_OP_reg0 R0
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/ARM/float-stack-arg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

define arm_aapcscc float @fn1(i32 %p1, i32 %p2, i32 %p3, i32 %p4, float returned %p5) #0 !dbg !7 {
; CHECK-LABEL: bb.0.entry:
; CHECK-NEXT: DBG_VALUE %fixed-stack.0, $noreg, ![[P5]], !DIExpression(DW_OP_deref)
; CHECK-NEXT: DBG_VALUE %fixed-stack.0, 0, ![[P5]]
entry:
call void @llvm.dbg.value(metadata float %p5, metadata !17, metadata !DIExpression()), !dbg !18
ret float %p5, !dbg !19
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/DebugInfo/COFF/pieces.ll
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@


; ASM-LABEL: nested: # @nested
; ASM: #DEBUG_VALUE: nested:o <- [DW_OP_deref] $rcx
; ASM: #DEBUG_VALUE: nested:o <- [DW_OP_deref] [$rcx+0]
; ASM: movl 12(%rcx), %eax
; ASM: [[p_start:\.Ltmp[0-9]+]]:
; ASM: #DEBUG_VALUE: nested:p <- [DW_OP_LLVM_fragment 32 32] $eax
Expand Down Expand Up @@ -204,7 +204,7 @@
; OBJ: DisplayName: nested
; OBJ: }
; OBJ: LocalSym {
; OBJ: Type: Nested
; OBJ: Type: Nested&
; OBJ: VarName: o
; OBJ: }
; OBJ: DefRangeRegisterRelSym {
Expand Down Expand Up @@ -437,7 +437,7 @@ attributes #5 = { nounwind }
!70 = !{!71, !72}
!71 = !DILocalVariable(name: "o", arg: 1, scope: !61, file: !1, line: 27, type: !64)
!72 = !DILocalVariable(name: "p", scope: !61, file: !1, line: 28, type: !53)
!73 = !DIExpression()
!73 = !DIExpression(DW_OP_deref)
!74 = !DILocation(line: 27, column: 26, scope: !61)
!75 = !DILocation(line: 28, column: 18, scope: !61)
!76 = !DILocation(line: 28, column: 22, scope: !61)
Expand Down
10 changes: 3 additions & 7 deletions llvm/test/DebugInfo/X86/dbg-addr-dse.ll
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
; RUN: FileCheck %s < %t.s --check-prefix=ASM
; RUN: llvm-dwarfdump %t.o | FileCheck %s --check-prefix=DWARF

; XFAIL: *
; See PR41992, the third and final dbg.value disappears after
; LiveDebugVariables.

; In this example, the variable lives mostly in memory, but at the point of the
; assignment to global, it lives nowhere, and is described as the constant
; value 1.
Expand Down Expand Up @@ -50,12 +46,12 @@ entry:
}

; ASM-LABEL: f: # @f
; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X:[0-9]+]], DW_OP_deref] $rsp
; ASM: movl %ecx, [[OFF_X]](%rsp)
; ASM: movl %ecx, [[OFF_X:[0-9]+]](%rsp)
; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]]] [$rsp+0]
; ASM: callq escape
; ASM: #DEBUG_VALUE: f:x <- 1
; ASM: movl $1, global(%rip)
; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]], DW_OP_deref] $rsp
; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]]] [$rsp+0]
; ASM: movl $2, [[OFF_X]](%rsp)
; ASM: callq escape
; ASM: retq
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/X86/dbg-addr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
; is control-dependent.

; CHECK-LABEL: use_dbg_addr:
; CHECK: #DEBUG_VALUE: use_dbg_addr:o <- [DW_OP_deref] $rsp
; CHECK: #DEBUG_VALUE: use_dbg_addr:o <- [$rsp+0]

; DWARF: DW_TAG_variable
; DWARF-NEXT: DW_AT_location (DW_OP_fbreg +0)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/X86/live-debug-variables.ll
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
; CHECK: .debug_loc contents:
; CHECK-NEXT: 0x00000000:
; We currently emit an entry for the function prologue, too, which could be optimized away.
; CHECK: (0x0000000000000010, 0x0000000000000072): DW_OP_reg3 RBX
; CHECK: (0x0000000000000018, 0x0000000000000072): DW_OP_reg3 RBX
; We should only have one entry inside the function.
; CHECK-NOT: :

Expand Down
16 changes: 6 additions & 10 deletions llvm/test/DebugInfo/X86/live-debug-vars-dse.mir
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# RUN: llc -start-after=machine-scheduler %s -o - | FileCheck %s

# XFAIL: *
# See PR41992, the third and final dbg.value disappears after
# LiveDebugVariables.

# C source:
# void escape(int *);
# extern int global;
Expand All @@ -17,12 +13,12 @@

# CHECK-LABEL: f: # @f
# CHECK: movl %ecx, [[OFF_X:[0-9]+]](%rsp)
# CHECK: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]], DW_OP_deref] $rsp
# CHECK: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]]] [$rsp+0]
# CHECK: leaq [[OFF_X]](%rsp), %rsi
# CHECK: callq escape
# CHECK: #DEBUG_VALUE: f:x <- 1
# CHECK: movl $1, global(%rip)
# CHECK: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]], DW_OP_deref] $rsp
# CHECK: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]]] [$rsp+0]
# CHECK: movl $2, [[OFF_X]](%rsp)
# CHECK: callq escape
# CHECK: retq
Expand All @@ -46,11 +42,11 @@
entry:
%x.addr = alloca i32, align 4
store i32 %x, i32* %x.addr, align 4
call void @llvm.dbg.value(metadata i32* %x.addr, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !14
call void @llvm.dbg.value(metadata i32* %x.addr, metadata !13, metadata !DIExpression()), !dbg !14
call void @escape(i32* %x.addr), !dbg !15
call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()), !dbg !16
store i32 1, i32* @global, align 4, !dbg !17
call void @llvm.dbg.value(metadata i32* %x.addr, metadata !13, metadata !DIExpression(DW_OP_deref)), !dbg !18
call void @llvm.dbg.value(metadata i32* %x.addr, metadata !13, metadata !DIExpression()), !dbg !18
store i32 2, i32* %x.addr, align 4, !dbg !18
call void @escape(i32* %x.addr), !dbg !19
ret void, !dbg !20
Expand Down Expand Up @@ -132,15 +128,15 @@ body: |
%0 = COPY $ecx
MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 :: (store 4 into %ir.x.addr)
DBG_VALUE %stack.0.x.addr, $noreg, !13, !DIExpression(DW_OP_deref), debug-location !14
DBG_VALUE %stack.0.x.addr, 0, !13, !DIExpression(), debug-location !14
ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15
%1 = LEA64r %stack.0.x.addr, 1, _, 0, _
$rcx = COPY %1, debug-location !15
CALL64pcrel32 @escape, csr_win64, implicit $rsp, implicit $ssp, implicit $rcx, implicit-def $rsp, implicit-def $ssp, debug-location !15
ADJCALLSTACKUP64 32, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !15
DBG_VALUE 1, _, !13, !DIExpression(), debug-location !16
MOV32mi $rip, 1, _, @global, _, 1, debug-location !17 :: (store 4 into @global)
DBG_VALUE %stack.0.x.addr, $noreg, !13, !DIExpression(DW_OP_deref), debug-location !18
DBG_VALUE %stack.0.x.addr, 0, !13, !DIExpression(), debug-location !18
MOV32mi %stack.0.x.addr, 1, _, 0, _, 2, debug-location !18 :: (store 4 into %ir.x.addr)
ADJCALLSTACKDOWN64 32, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !19
$rcx = COPY %1, debug-location !19
Expand Down
14 changes: 5 additions & 9 deletions llvm/test/DebugInfo/X86/op_deref.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,22 @@
; RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF3

; DWARF4: DW_AT_location [DW_FORM_sec_offset] (0x00000000
; DWARF4-NEXT: {{.*}}: DW_OP_breg1 RDX+0{{$}}
; DWARF4-NEXT: {{.*}}: DW_OP_breg6 RBP-{{[0-9]+}}, DW_OP_deref)
; DWARF4-NEXT: {{.*}}: DW_OP_breg1 RDX+0, DW_OP_deref

; DWARF3: DW_AT_location [DW_FORM_data4] (0x00000000
; DWARF3-NEXT: {{.*}}: DW_OP_breg1 RDX+0{{$}}
; DWARF3-NEXT: {{.*}}: DW_OP_breg6 RBP-{{[0-9]+}}, DW_OP_deref)
; DWARF3-NEXT: {{.*}}: DW_OP_breg1 RDX+0, DW_OP_deref

; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla")

; Check the DEBUG_VALUE comments for good measure.
; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s -check-prefix=ASM-CHECK
; vla should have a register-indirect address at one point.
; ASM-CHECK: DEBUG_VALUE: vla <- [DW_OP_deref] $rdx
; vla ptr is spilt too, it should have a stack location,
; ASM-CHECK: DEBUG_VALUE: vla <- [DW_OP_constu {{[0-9]+}}, DW_OP_minus, DW_OP_deref] [$rbp+0]
; ASM-CHECK: DEBUG_VALUE: vla <- [DW_OP_deref] [$rdx+0]
; ASM-CHECK: DW_OP_breg1

; RUN: llvm-as %s -o - | llvm-dis - | FileCheck %s --check-prefix=PRETTY-PRINT
; PRETTY-PRINT: DIExpression()
; PRETTY-PRINT: DIExpression(DW_OP_deref)

define void @testVLAwithSize(i32 %s) nounwind uwtable ssp !dbg !5 {
entry:
Expand Down Expand Up @@ -108,4 +104,4 @@ declare void @llvm.stackrestore(i8*) nounwind
!27 = !DILocation(line: 8, column: 1, scope: !13)
!28 = !DIFile(filename: "bar.c", directory: "/Users/echristo/tmp")
!29 = !{i32 1, !"Debug Info Version", i32 3}
!30 = !DIExpression()
!30 = !DIExpression(DW_OP_deref)
10 changes: 5 additions & 5 deletions llvm/test/DebugInfo/X86/parameters.ll
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
; CHECK: DW_AT_name{{.*}} = "func"
; CHECK: DW_TAG_formal_parameter
; CHECK: DW_AT_location {{.*}}
; CHECK-NEXT: DW_OP_breg4 RSI+0)
; CHECK-NEXT: DW_OP_breg4 RSI+0, DW_OP_deref
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name{{.*}} = "f"

Expand All @@ -38,8 +38,8 @@
; CHECK: DW_AT_location{{.*}}(DW_OP_fbreg +23)
; CHECK: DW_TAG_formal_parameter
; CHECK: DW_AT_location{{.*}}(
; CHECK-NEXT: {{.*}}: DW_OP_breg4 RSI+0{{$}}
; CHECK-NEXT: {{.*}}: DW_OP_breg7 RSP+8, DW_OP_deref)
; CHECK-NEXT: {{.*}}: DW_OP_breg4 RSI+0, DW_OP_deref
; CHECK-NEXT: {{.*}}: DW_OP_breg7 RSP+8, DW_OP_deref, DW_OP_deref)
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name{{.*}} = "g"

Expand All @@ -48,7 +48,7 @@
; Function Attrs: uwtable
define void @_ZN7pr147634funcENS_3fooE(%"struct.pr14763::foo"* noalias sret %agg.result, %"struct.pr14763::foo"* %f) #0 !dbg !4 {
entry:
call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %f, metadata !22, metadata !DIExpression()), !dbg !24
call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %f, metadata !22, metadata !DIExpression(DW_OP_deref)), !dbg !24
call void @_ZN7pr147633fooC1ERKS0_(%"struct.pr14763::foo"* %agg.result, %"struct.pr14763::foo"* %f), !dbg !25
ret void, !dbg !25
}
Expand All @@ -65,7 +65,7 @@ entry:
%frombool = zext i1 %b to i8
store i8 %frombool, i8* %b.addr, align 1
call void @llvm.dbg.declare(metadata i8* %b.addr, metadata !26, metadata !DIExpression()), !dbg !27
call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %g, metadata !28, metadata !DIExpression()), !dbg !27
call void @llvm.dbg.declare(metadata %"struct.pr14763::foo"* %g, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !27
%0 = load i8, i8* %b.addr, align 1, !dbg !29
%tobool = trunc i8 %0 to i1, !dbg !29
br i1 %tobool, label %if.then, label %if.end, !dbg !29
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/DebugInfo/X86/safestack-byval.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
; }

; CHECK: ![[ZZZ:.*]] = !DILocalVariable(name: "zzz",
; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_constu, 400, DW_OP_minus, DW_OP_deref)
; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_deref, DW_OP_constu, 400, DW_OP_minus)

%struct.S = type { [100 x i32] }

Expand Down Expand Up @@ -78,7 +78,7 @@ attributes #2 = { argmemonly nounwind }
!20 = !{i32 2, !"Debug Info Version", i32 3}
!21 = !{!"clang version 3.8.0 (trunk 254107) (llvm/trunk 254109)"}
!22 = !DILocation(line: 8, column: 9, scope: !12)
!23 = !DIExpression(DW_OP_constu, 400, DW_OP_minus)
!23 = !DIExpression(DW_OP_deref, DW_OP_constu, 400, DW_OP_minus)
!24 = !DILocation(line: 8, column: 28, scope: !12)
!25 = !DIExpression()
!26 = !DILocation(line: 9, column: 10, scope: !12)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/X86/spill-indirect-nrvo.ll
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
; }

; CHECK-LABEL: _Z10get_stringv:
; CHECK: #DEBUG_VALUE: get_string:result <- [DW_OP_deref] $rdi
; CHECK: #DEBUG_VALUE: get_string:result <- [$rdi+0]
; CHECK: movq %rdi, [[OFFS:[0-9]+]](%rsp) # 8-byte Spill
; CHECK: #DEBUG_VALUE: get_string:result <- [DW_OP_plus_uconst [[OFFS]], DW_OP_deref] [$rsp+0]
; CHECK: callq _ZN6stringC1Ei
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/X86/spill-nontrivial-param.ll
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
; }

; CHECK-LABEL: _Z3foo10NonTrivial:
; CHECK: #DEBUG_VALUE: foo:nt <- [DW_OP_deref] $rdi
; CHECK: #DEBUG_VALUE: foo:nt <- [$rdi+0]
; CHECK: movq %rdi, -8(%rsp) # 8-byte Spill
; CHECK: #DEBUG_VALUE: foo:nt <- [DW_OP_constu 8, DW_OP_minus, DW_OP_deref] [$rsp+0]
; CHECK: #APP
Expand Down
85 changes: 0 additions & 85 deletions llvm/test/DebugInfo/X86/stack-arg-deref.ll

This file was deleted.

18 changes: 2 additions & 16 deletions llvm/test/DebugInfo/X86/vla.ll
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=asm %s -o - | FileCheck %s
; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=obj %s -o - | llvm-dwarfdump - --name=a | FileCheck --check-prefix=OBJFILE %s
; REQUIRES: object-emission
;
; Ensure that we generate an indirect location for the variable length array a.
;
; CHECK: ##DEBUG_VALUE: vla:a <- [DW_OP_deref] {{\$r[a-z]+}}
; CHECK: ##DEBUG_VALUE: vla:a <- [DW_OP_deref] [{{\$r[a-z]+}}+0]
; CHECK: DW_OP_breg{{[0-9]}}
;
; Ensure there's only one level of indirection in the vla location -- it should
; be a memory location. Base register can be any allocatable one; variables are
; filtered by --name arg to llvm-dwarfdump.
;
; OBJFILE: DW_TAG_variable
; OBJFILE: DW_AT_location
; OBJFILE-NEXT: ): DW_OP_breg{{[0-9]+}} R{{[0-9A-Z]+}}+0)
; OBJFILE: DW_AT_name ("a")
;
; rdar://problem/13658587
;
; generated from:
Expand Down Expand Up @@ -47,7 +33,7 @@ entry:
%2 = call i8* @llvm.stacksave(), !dbg !17
store i8* %2, i8** %saved_stack, !dbg !17
%vla = alloca i32, i64 %1, align 16, !dbg !17
call void @llvm.dbg.declare(metadata i32* %vla, metadata !18, metadata !DIExpression()), !dbg !17
call void @llvm.dbg.declare(metadata i32* %vla, metadata !18, metadata !DIExpression(DW_OP_deref)), !dbg !17
%arrayidx = getelementptr inbounds i32, i32* %vla, i64 0, !dbg !22
store i32 42, i32* %arrayidx, align 4, !dbg !22
%3 = load i32, i32* %n.addr, align 4, !dbg !23
Expand Down