summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-02-17 22:20:08 +0000
committerAdrian Prantl <aprantl@apple.com>2016-02-17 22:20:08 +0000
commit3b89e6634c33188e5635416d181d9ca33fcbcc65 (patch)
tree48bd53d8ea0b20852891aa2d6e0bdeff42823192 /llvm/lib/CodeGen
parent6f4746b11aedb9de22c1b5c0ae936690ff67a432 (diff)
downloadbcm5719-llvm-3b89e6634c33188e5635416d181d9ca33fcbcc65.tar.gz
bcm5719-llvm-3b89e6634c33188e5635416d181d9ca33fcbcc65.zip
DwarfDebug: Don't drop the DIExpression just because a variable is
described by an immediate. Found via http://reviews.llvm.org/D16867 Thanks to Paul Robinson for pointing this out. <rdar://problem/24456528> llvm-svn: 261168
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 5febd9fb380..56856c7ee3f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -504,9 +504,20 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
addVariableAddress(DV, *VariableDie, Location);
} else if (RegOp.getReg())
addVariableAddress(DV, *VariableDie, MachineLocation(RegOp.getReg()));
- } else if (DVInsn->getOperand(0).isImm())
- addConstantValue(*VariableDie, DVInsn->getOperand(0), DV.getType());
- else if (DVInsn->getOperand(0).isFPImm())
+ } else if (DVInsn->getOperand(0).isImm()) {
+ // This variable is described by a single constant.
+ // Check whether it has a DIExpression.
+ auto *Expr = DV.getSingleExpression();
+ if (Expr && Expr->getNumElements()) {
+ DIELoc *Loc = new (DIEValueAllocator) DIELoc;
+ DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
+ // If there is an expression, emit raw unsigned bytes.
+ DwarfExpr.AddUnsignedConstant(DVInsn->getOperand(0).getImm());
+ DwarfExpr.AddExpression(Expr->expr_op_begin(), Expr->expr_op_end());
+ addBlock(*VariableDie, dwarf::DW_AT_location, Loc);
+ } else
+ addConstantValue(*VariableDie, DVInsn->getOperand(0), DV.getType());
+ } else if (DVInsn->getOperand(0).isFPImm())
addConstantFPValue(*VariableDie, DVInsn->getOperand(0));
else if (DVInsn->getOperand(0).isCImm())
addConstantValue(*VariableDie, DVInsn->getOperand(0).getCImm(),
OpenPOWER on IntegriCloud