X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FDebugInfo.cpp;h=c59b77eca0a337f06788b8efa4b5d7163ab68d89;hb=0c5071f56198367ea2b29f8e34ddb9ecd1773985;hp=b97358545a53ba4fa1dfe05ff6f0fda5e904f66f;hpb=807538b567af91393264a425ed985b57bd908e71;p=oota-llvm.git diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index b97358545a5..c59b77eca0a 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DIBuilder.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" @@ -39,7 +40,6 @@ bool DIDescriptor::Verify() const { return DbgNode && (DIDerivedType(DbgNode).Verify() || DICompositeType(DbgNode).Verify() || DIBasicType(DbgNode).Verify() || - DITrivialType(DbgNode).Verify() || DIVariable(DbgNode).Verify() || DISubprogram(DbgNode).Verify() || DIGlobalVariable(DbgNode).Verify() || DIFile(DbgNode).Verify() || DICompileUnit(DbgNode).Verify() || DINameSpace(DbgNode).Verify() || @@ -151,14 +151,40 @@ uint64_t DIVariable::getAddrElement(unsigned Idx) const { /// getInlinedAt - If this variable is inlined then return inline location. MDNode *DIVariable::getInlinedAt() const { return getNodeField(DbgNode, 7); } +bool DIVariable::isVariablePiece() const { + return hasComplexAddress() && getAddrElement(0) == DIBuilder::OpPiece; +} + +uint64_t DIVariable::getPieceOffset() const { + assert(isVariablePiece()); + return getAddrElement(1); +} + +uint64_t DIVariable::getPieceSize() const { + assert(isVariablePiece()); + return getAddrElement(2); +} + +/// Return the size reported by the variable's type. +unsigned DIVariable::getSizeInBits(const DITypeIdentifierMap &Map) { + DIType Ty = getType().resolve(Map); + // Follow derived types until we reach a type that + // reports back a size. + while (Ty.isDerivedType() && !Ty.getSizeInBits()) { + DIDerivedType DT(&*Ty); + Ty = DT.getTypeDerivedFrom().resolve(Map); + } + assert(Ty.getSizeInBits() && "type with size 0"); + return Ty.getSizeInBits(); +} + + + + //===----------------------------------------------------------------------===// // Predicates //===----------------------------------------------------------------------===// -bool DIDescriptor::isTrivialType() const { - return DbgNode && getTag() == dwarf::DW_TAG_unspecified_parameters; -} - bool DIDescriptor::isSubroutineType() const { return isCompositeType() && getTag() == dwarf::DW_TAG_subroutine_type; } @@ -233,8 +259,7 @@ bool DIDescriptor::isVariable() const { /// isType - Return true if the specified tag is legal for DIType. bool DIDescriptor::isType() const { - return isBasicType() || isCompositeType() || isDerivedType() || - isTrivialType(); + return isBasicType() || isCompositeType() || isDerivedType(); } /// isSubprogram - Return true if the specified tag is legal for @@ -250,12 +275,6 @@ bool DIDescriptor::isGlobalVariable() const { getTag() == dwarf::DW_TAG_constant); } -/// isUnspecifiedParmeter - Return true if the specified tag is -/// DW_TAG_unspecified_parameters. -bool DIDescriptor::isUnspecifiedParameter() const { - return DbgNode && getTag() == dwarf::DW_TAG_unspecified_parameters; -} - /// isScope - Return true if the specified tag is one of the scope /// related tag. bool DIDescriptor::isScope() const { @@ -459,7 +478,7 @@ bool DIType::Verify() const { // FIXME: Sink this into the various subclass verifies. uint16_t Tag = getTag(); - if (!isBasicType() && !isTrivialType() && Tag != dwarf::DW_TAG_const_type && + if (!isBasicType() && Tag != dwarf::DW_TAG_const_type && Tag != dwarf::DW_TAG_volatile_type && Tag != dwarf::DW_TAG_pointer_type && Tag != dwarf::DW_TAG_ptr_to_member_type && Tag != dwarf::DW_TAG_reference_type && @@ -474,8 +493,6 @@ bool DIType::Verify() const { // a CompositeType. if (isBasicType()) return DIBasicType(DbgNode).Verify(); - else if (isTrivialType()) - return DITrivialType(DbgNode).Verify(); else if (isCompositeType()) return DICompositeType(DbgNode).Verify(); else if (isDerivedType()) @@ -489,10 +506,6 @@ bool DIBasicType::Verify() const { return isBasicType() && DbgNode->getNumOperands() == 10; } -bool DITrivialType::Verify() const { - return isTrivialType() && DbgNode->getNumOperands() == 1; -} - /// Verify - Verify that a derived type descriptor is well formed. bool DIDerivedType::Verify() const { // Make sure DerivedFrom @ field 9 is TypeRef. @@ -922,6 +935,19 @@ DIVariable llvm::cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext) { return DIVariable(MDNode::get(VMContext, Elts)); } + +/// getEntireVariable - Remove OpPiece exprs from the variable. +DIVariable llvm::getEntireVariable(DIVariable DV) { + if (!DV.isVariablePiece()) + return DV; + + SmallVector Elts; + for (unsigned i = 0; i < 8; ++i) + Elts.push_back(DV->getOperand(i)); + + return DIVariable(MDNode::get(DV->getContext(), Elts)); +} + /// getDISubprogram - Find subprogram that is enclosing this scope. DISubprogram llvm::getDISubprogram(const MDNode *Scope) { DIDescriptor D(Scope); @@ -1297,7 +1323,7 @@ void DIEnumerator::printInternal(raw_ostream &OS) const { } void DIType::printInternal(raw_ostream &OS) const { - if (!DbgNode || isTrivialType()) + if (!DbgNode) return; StringRef Res = getName(); @@ -1411,6 +1437,10 @@ void DIVariable::printInternal(raw_ostream &OS) const { OS << " [" << Res << ']'; OS << " [line " << getLineNumber() << ']'; + + if (isVariablePiece()) + OS << " [piece, size " << getPieceSize() + << ", offset " << getPieceOffset() << ']'; } void DIObjCProperty::printInternal(raw_ostream &OS) const {