[llvm-commits] [llvm] r136802 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Bob Wilson
bob.wilson at apple.com
Wed Aug 3 12:42:51 PDT 2011
Author: bwilson
Date: Wed Aug 3 14:42:51 2011
New Revision: 136802
URL: http://llvm.org/viewvc/llvm-project?rev=136802&view=rev
Log:
Some revisions to Devang's change r136759 for merged global debug info.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=136802&r1=136801&r2=136802&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Aug 3 14:42:51 2011
@@ -955,12 +955,13 @@
static const ConstantExpr *getMergedGlobalExpr(const Value *V) {
const ConstantExpr *CE = dyn_cast_or_null<ConstantExpr>(V);
if (!CE || CE->getNumOperands() != 3 ||
- CE->getOpcode() != Instruction::GetElementPtr ||
- !isa<PointerType>(CE->getOperand(0)->getType()))
+ CE->getOpcode() != Instruction::GetElementPtr)
return NULL;
- // First operand points to a global value.
- if (!isa<GlobalValue>(CE->getOperand(0)))
+ // First operand points to a global struct.
+ Value *Ptr = CE->getOperand(0);
+ if (!isa<GlobalValue>(Ptr) ||
+ !isa<StructType>(cast<PointerType>(Ptr->getType())->getElementType()))
return NULL;
// Second operand is zero.
@@ -975,23 +976,6 @@
return CE;
}
-// getMergedGlobalElementOffset - If CE is accessing a merged global
-// then find byte offset of the element accessed by CE. This must be
-// used only CE returned by getMergedGlobalExpr(). See above.
-static uint64_t getMergedGlobalElementOffset(const TargetData &TD,
- const ConstantExpr *CE) {
- assert (getMergedGlobalExpr(CE) && "This is not a merged global!");
- uint64_t e = cast<ConstantInt>(CE->getOperand(2))->getZExtValue();
- if (e == 0) return 0;
-
- uint64_t Offset = 0;
- const PointerType *PTy = dyn_cast<PointerType>(CE->getOperand(0)->getType());
- const StructType *STy = dyn_cast<StructType>(PTy->getElementType());
- for (uint64_t i = 0; i != e; ++i)
- Offset += TD.getTypeAllocSize(STy->getElementType(i));
- return Offset;
-}
-
/// constructGlobalVariableDIE - Construct global variable DIE.
void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
DIGlobalVariable GV(N);
@@ -1060,12 +1044,14 @@
else if (const ConstantExpr *CE = getMergedGlobalExpr(N->getOperand(11))) {
// GV is a merged global.
DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
+ Value *Ptr = CE->getOperand(0);
TheCU->addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
TheCU->addLabel(Block, 0, dwarf::DW_FORM_udata,
- Asm->Mang->getSymbol(cast<GlobalValue>(CE->getOperand(0))));
+ Asm->Mang->getSymbol(cast<GlobalValue>(Ptr)));
TheCU->addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
+ SmallVector<Value*, 3> Idx(CE->op_begin()+1, CE->op_end());
TheCU->addUInt(Block, 0, dwarf::DW_FORM_udata,
- getMergedGlobalElementOffset(Asm->getTargetData(), CE));
+ Asm->getTargetData().getIndexedOffset(Ptr->getType(), Idx));
TheCU->addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
TheCU->addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block);
}
More information about the llvm-commits
mailing list