Skip to content

Commit 236fd70

Browse files
jmorsevedantk
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 03063b2 commit 236fd70

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

5568+
bool IsIndirect = false;
55685569
Optional<MachineOperand> Op;
55695570
// Some arguments' frame index is recorded during argument lowering.
55705571
int FI = FuncInfo.getArgumentFrameIndex(Arg);
@@ -5586,6 +5587,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
55865587
}
55875588
if (Reg) {
55885589
Op = MachineOperand::CreateReg(Reg, false);
5590+
IsIndirect = IsDbgDeclare;
55895591
}
55905592
}
55915593

@@ -5652,6 +5654,7 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
56525654
}
56535655

56545656
Op = MachineOperand::CreateReg(VMI->second, false);
5657+
IsIndirect = IsDbgDeclare;
56555658
} else if (ArgRegsAndSizes.size() > 1) {
56565659
// This was split due to the calling convention, and no virtual register
56575660
// mapping exists for the value.
@@ -5665,26 +5668,9 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(
56655668

56665669
assert(Variable->isValidLocationForIntrinsic(DL) &&
56675670
"Expected inlined-at fields to agree");
5668-
5669-
// If the argument arrives in a stack slot, then what the IR thought was a
5670-
// normal Value is actually in memory, and we must add a deref to load it.
5671-
if (Op->isFI()) {
5672-
int FI = Op->getIndex();
5673-
unsigned Size = DAG.getMachineFunction().getFrameInfo().getObjectSize(FI);
5674-
if (Expr->isImplicit()) {
5675-
SmallVector<uint64_t, 2> Ops = {dwarf::DW_OP_deref_size, Size};
5676-
Expr = DIExpression::prependOpcodes(Expr, Ops);
5677-
} else {
5678-
Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
5679-
}
5680-
}
5681-
5682-
// If this location was specified with a dbg.declare, then it and its
5683-
// expression calculate the address of the variable. Append a deref to
5684-
// force it to be a memory location.
5685-
if (IsDbgDeclare)
5671+
IsIndirect = (Op->isReg()) ? IsIndirect : true;
5672+
if (IsIndirect)
56865673
Expr = DIExpression::append(Expr, {dwarf::DW_OP_deref});
5687-
56885674
FuncInfo.ArgDbgValues.push_back(
56895675
BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE), false,
56905676
*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)