Skip to content

Commit 04d7337

Browse files
jmorsezmodem
authored andcommitted
Revert "[DebugInfo][DAG] Distinguish different kinds of location indirection"
This reverts commit 3137fe4. I'm backing out D68945, which this patch is a follow up for. It'll be re-landed when D68945 is fixed. The changes to dbg-value-func-arg.ll occur because our handling of certain kinds of location now mixes up indirection that happens at different points in a DIExpression. While this is a regression, it's a return to the prior behaviour while a better patch is sought. (cherry picked from commit ece7614)
1 parent c170172 commit 04d7337

File tree

3 files changed

+7
-106
lines changed

3 files changed

+7
-106
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5622,6 +5622,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
56225622
MachineFunction &MF = DAG.getMachineFunction();
56235623
const TargetInstrInfo *TII = DAG.getSubtarget().getInstrInfo();
56245624

5625+
bool IsIndirect = false;
56255626
Optional<MachineOperand> Op;
56265627
// Some arguments' frame index is recorded during argument lowering.
56275628
int FI = FuncInfo.getArgumentFrameIndex(Arg);
@@ -5643,6 +5644,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
56435644
}
56445645
if (Reg) {
56455646
Op = MachineOperand::CreateReg(Reg, false);
5647+
IsIndirect = IsDbgDeclare;
56465648
}
56475649
}
56485650

@@ -5709,6 +5711,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
57095711
}
57105712

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

57235726
assert(Variable->isValidLocationForIntrinsic(DL) &&
57245727
"Expected inlined-at fields to agree");
5725-
5726-
// If the argument arrives in a stack slot, then what the IR thought was a
5727-
// normal Value is actually in memory, and we must add a deref to load it.
5728-
if (Op->isFI()) {
5729-
int FI = Op->getIndex();
5730-
unsigned Size = DAG.getMachineFunction().getFrameInfo().getObjectSize(FI);
5731-
if (Expr->isImplicit()) {
5732-
SmallVector<uint64_t, 2> Ops = {dwarf::DW_OP_deref_size, Size};
5733-
Expr = DIExpression::prependOpcodes(Expr, Ops);
5734-
} else {
5735-
Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
5736-
}
5737-
}
5738-
5739-
// If this location was specified with a dbg.declare, then it and its
5740-
// expression calculate the address of the variable. Append a deref to
5741-
// force it to be a memory location.
5742-
if (IsDbgDeclare)
5728+
IsIndirect = (Op->isReg()) ? IsIndirect : true;
5729+
if (IsIndirect)
57435730
Expr = DIExpression::append(Expr, {dwarf::DW_OP_deref});
5744-
57455731
FuncInfo.ArgDbgValues.push_back(
57465732
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), false,
57475733
*Op, Variable, Expr));

llvm/test/CodeGen/X86/dbg-value-func-arg.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ define dso_local %struct.bar* @func1(%struct.bar* readnone returned %0, i32 %1,
3434
; CHECK-DAG: DBG_VALUE %fixed-stack.0, $noreg, {{.*}}, !DIExpression(DW_OP_deref, DW_OP_LLVM_fragment, 32, 32),
3535
; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, !DIExpression(DW_OP_deref),
3636
; CHECK-DAG: DBG_VALUE %fixed-stack.2, $noreg, {{.*}}, !DIExpression(DW_OP_deref),
37-
; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, !DIExpression(DW_OP_deref_size, 4, DW_OP_plus_uconst, 144, DW_OP_stack_value),
38-
; 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),
37+
; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, !DIExpression(DW_OP_plus_uconst, 144, DW_OP_deref, DW_OP_stack_value),
38+
; CHECK-DAG: DBG_VALUE %fixed-stack.3, $noreg, {{.*}}, !DIExpression(DW_OP_plus_uconst, 144, DW_OP_deref, DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32),
3939

4040
call void @llvm.dbg.value(metadata i32 %2, metadata !24, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !26
4141
call void @llvm.dbg.value(metadata i32* %3, metadata !24, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg !26

llvm/test/DebugInfo/X86/stack-arg-deref.ll

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)