Skip to content

Commit ece7614

Browse files
committed
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.
1 parent ed5998d commit ece7614

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
@@ -5583,6 +5583,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
55835583
MachineFunction &MF = DAG.getMachineFunction();
55845584
const TargetInstrInfo *TII = DAG.getSubtarget().getInstrInfo();
55855585

5586+
bool IsIndirect = false;
55865587
Optional<MachineOperand> Op;
55875588
// Some arguments' frame index is recorded during argument lowering.
55885589
int FI = FuncInfo.getArgumentFrameIndex(Arg);
@@ -5604,6 +5605,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
56045605
}
56055606
if (Reg) {
56065607
Op = MachineOperand::CreateReg(Reg, false);
5608+
IsIndirect = IsDbgDeclare;
56075609
}
56085610
}
56095611

@@ -5670,6 +5672,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
56705672
}
56715673

56725674
Op = MachineOperand::CreateReg(VMI->second, false);
5675+
IsIndirect = IsDbgDeclare;
56735676
} else if (ArgRegsAndSizes.size() > 1) {
56745677
// This was split due to the calling convention, and no virtual register
56755678
// mapping exists for the value.
@@ -5683,26 +5686,9 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
56835686

56845687
assert(Variable->isValidLocationForIntrinsic(DL) &&
56855688
"Expected inlined-at fields to agree");
5686-
5687-
// If the argument arrives in a stack slot, then what the IR thought was a
5688-
// normal Value is actually in memory, and we must add a deref to load it.
5689-
if (Op->isFI()) {
5690-
int FI = Op->getIndex();
5691-
unsigned Size = DAG.getMachineFunction().getFrameInfo().getObjectSize(FI);
5692-
if (Expr->isImplicit()) {
5693-
SmallVector<uint64_t, 2> Ops = {dwarf::DW_OP_deref_size, Size};
5694-
Expr = DIExpression::prependOpcodes(Expr, Ops);
5695-
} else {
5696-
Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
5697-
}
5698-
}
5699-
5700-
// If this location was specified with a dbg.declare, then it and its
5701-
// expression calculate the address of the variable. Append a deref to
5702-
// force it to be a memory location.
5703-
if (IsDbgDeclare)
5689+
IsIndirect = (Op->isReg()) ? IsIndirect : true;
5690+
if (IsIndirect)
57045691
Expr = DIExpression::append(Expr, {dwarf::DW_OP_deref});
5705-
57065692
FuncInfo.ArgDbgValues.push_back(
57075693
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), false,
57085694
*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)