Avoid DIDescriptor::getNode(). Use overloaded operators instead.

llvm-svn: 103272
This commit is contained in:
Devang Patel 2010-05-07 18:11:54 +00:00
parent b3c5c4611c
commit cfa8e9d45f
4 changed files with 153 additions and 151 deletions

View File

@ -63,7 +63,9 @@ namespace llvm {
bool Verify() const { return DbgNode != 0; } bool Verify() const { return DbgNode != 0; }
MDNode *getNode() const { return DbgNode; } MDNode *getNode() const { return DbgNode; }
operator MDNode *() const { return DbgNode; }
MDNode *operator ->() const { return DbgNode; }
unsigned getVersion() const { unsigned getVersion() const {
return getUnsignedField(0) & LLVMDebugVersionMask; return getUnsignedField(0) & LLVMDebugVersionMask;
@ -397,7 +399,7 @@ namespace llvm {
DICompositeType DCT(getFieldAs<DICompositeType>(8)); DICompositeType DCT(getFieldAs<DICompositeType>(8));
if (DCT.Verify()) { if (DCT.Verify()) {
DIArray A = DCT.getTypeArray(); DIArray A = DCT.getTypeArray();
DIType T(A.getElement(0).getNode()); DIType T(A.getElement(0));
return T.getName(); return T.getName();
} }
DIType T(getFieldAs<DIType>(8)); DIType T(getFieldAs<DIType>(8));

View File

@ -271,9 +271,9 @@ void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) {
// which, due to uniquing, has merged with the source. We shield clients from // which, due to uniquing, has merged with the source. We shield clients from
// this detail by allowing a value to be replaced with replaceAllUsesWith() // this detail by allowing a value to be replaced with replaceAllUsesWith()
// itself. // itself.
if (getNode() != D.getNode()) { if (getNode() != D) {
MDNode *Node = DbgNode; MDNode *Node = DbgNode;
Node->replaceAllUsesWith(D.getNode()); Node->replaceAllUsesWith(D);
Node->destroy(); Node->destroy();
} }
} }
@ -394,7 +394,7 @@ uint64_t DIDerivedType::getOriginalTypeSize() const {
if (!BaseType.isValid()) if (!BaseType.isValid())
return getSizeInBits(); return getSizeInBits();
if (BaseType.isDerivedType()) if (BaseType.isDerivedType())
return DIDerivedType(BaseType.getNode()).getOriginalTypeSize(); return DIDerivedType(BaseType).getOriginalTypeSize();
else else
return BaseType.getSizeInBits(); return BaseType.getSizeInBits();
} }
@ -410,7 +410,7 @@ bool DIVariable::isInlinedFnArgument(const Function *CurFn) {
return false; return false;
// This variable is not inlined function argument if its scope // This variable is not inlined function argument if its scope
// does not describe current function. // does not describe current function.
return !(DISubprogram(getContext().getNode()).describes(CurFn)); return !(DISubprogram(getContext()).describes(CurFn));
} }
/// describes - Return true if this subprogram provides debugging /// describes - Return true if this subprogram provides debugging
@ -691,7 +691,7 @@ DIArray DIFactory::GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys) {
Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext))); Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)));
else else
for (unsigned i = 0; i != NumTys; ++i) for (unsigned i = 0; i != NumTys; ++i)
Elts.push_back(Tys[i].getNode()); Elts.push_back(Tys[i]);
return DIArray(MDNode::get(VMContext,Elts.data(), Elts.size())); return DIArray(MDNode::get(VMContext,Elts.data(), Elts.size()));
} }
@ -744,7 +744,7 @@ DIFile DIFactory::CreateFile(StringRef Filename,
GetTagConstant(dwarf::DW_TAG_file_type), GetTagConstant(dwarf::DW_TAG_file_type),
MDString::get(VMContext, Filename), MDString::get(VMContext, Filename),
MDString::get(VMContext, Directory), MDString::get(VMContext, Directory),
CU.getNode() CU
}; };
return DIFile(MDNode::get(VMContext, &Elts[0], 4)); return DIFile(MDNode::get(VMContext, &Elts[0], 4));
@ -772,9 +772,9 @@ DIBasicType DIFactory::CreateBasicType(DIDescriptor Context,
unsigned Encoding) { unsigned Encoding) {
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_base_type), GetTagConstant(dwarf::DW_TAG_base_type),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
@ -797,9 +797,9 @@ DIBasicType DIFactory::CreateBasicTypeEx(DIDescriptor Context,
unsigned Encoding) { unsigned Encoding) {
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_base_type), GetTagConstant(dwarf::DW_TAG_base_type),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
SizeInBits, SizeInBits,
AlignInBits, AlignInBits,
@ -816,7 +816,7 @@ DIType DIFactory::CreateArtificialType(DIType Ty) {
return Ty; return Ty;
SmallVector<Value *, 9> Elts; SmallVector<Value *, 9> Elts;
MDNode *N = Ty.getNode(); MDNode *N = Ty;
assert (N && "Unexpected input DIType!"); assert (N && "Unexpected input DIType!");
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
if (Value *V = N->getOperand(i)) if (Value *V = N->getOperand(i))
@ -848,15 +848,15 @@ DIDerivedType DIFactory::CreateDerivedType(unsigned Tag,
DIType DerivedFrom) { DIType DerivedFrom) {
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(Tag), GetTagConstant(Tag),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
ConstantInt::get(Type::getInt32Ty(VMContext), Flags), ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
DerivedFrom.getNode(), DerivedFrom,
}; };
return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10));
} }
@ -876,15 +876,15 @@ DIDerivedType DIFactory::CreateDerivedTypeEx(unsigned Tag,
DIType DerivedFrom) { DIType DerivedFrom) {
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(Tag), GetTagConstant(Tag),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
SizeInBits, SizeInBits,
AlignInBits, AlignInBits,
OffsetInBits, OffsetInBits,
ConstantInt::get(Type::getInt32Ty(VMContext), Flags), ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
DerivedFrom.getNode(), DerivedFrom,
}; };
return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10)); return DIDerivedType(MDNode::get(VMContext, &Elts[0], 10));
} }
@ -907,16 +907,16 @@ DICompositeType DIFactory::CreateCompositeType(unsigned Tag,
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(Tag), GetTagConstant(Tag),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits), ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits), ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits), ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
ConstantInt::get(Type::getInt32Ty(VMContext), Flags), ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
DerivedFrom.getNode(), DerivedFrom,
Elements.getNode(), Elements,
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang),
ContainingType ContainingType
}; };
@ -940,16 +940,16 @@ DICompositeType DIFactory::CreateCompositeTypeEx(unsigned Tag,
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(Tag), GetTagConstant(Tag),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber), ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
SizeInBits, SizeInBits,
AlignInBits, AlignInBits,
OffsetInBits, OffsetInBits,
ConstantInt::get(Type::getInt32Ty(VMContext), Flags), ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
DerivedFrom.getNode(), DerivedFrom,
Elements.getNode(), Elements,
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang) ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
}; };
return DICompositeType(MDNode::get(VMContext, &Elts[0], 12)); return DICompositeType(MDNode::get(VMContext, &Elts[0], 12));
@ -975,18 +975,18 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_subprogram), GetTagConstant(dwarf::DW_TAG_subprogram),
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
MDString::get(VMContext, DisplayName), MDString::get(VMContext, DisplayName),
MDString::get(VMContext, LinkageName), MDString::get(VMContext, LinkageName),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
Ty.getNode(), Ty,
ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK), ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK),
ConstantInt::get(Type::getInt32Ty(VMContext), VIndex), ConstantInt::get(Type::getInt32Ty(VMContext), VIndex),
ContainingType.getNode(), ContainingType,
ConstantInt::get(Type::getInt1Ty(VMContext), isArtificial), ConstantInt::get(Type::getInt1Ty(VMContext), isArtificial),
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized) ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized)
}; };
@ -997,9 +997,9 @@ DISubprogram DIFactory::CreateSubprogram(DIDescriptor Context,
/// given declaration. /// given declaration.
DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration) { DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration) {
if (SPDeclaration.isDefinition()) if (SPDeclaration.isDefinition())
return DISubprogram(SPDeclaration.getNode()); return DISubprogram(SPDeclaration);
MDNode *DeclNode = SPDeclaration.getNode(); MDNode *DeclNode = SPDeclaration;
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_subprogram), GetTagConstant(dwarf::DW_TAG_subprogram),
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
@ -1032,13 +1032,13 @@ DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name,
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_variable), GetTagConstant(dwarf::DW_TAG_variable),
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
MDString::get(VMContext, DisplayName), MDString::get(VMContext, DisplayName),
MDString::get(VMContext, LinkageName), MDString::get(VMContext, LinkageName),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
Ty.getNode(), Ty,
ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
Val Val
@ -1063,11 +1063,11 @@ DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context,
DIType Ty) { DIType Ty) {
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(Tag), GetTagConstant(Tag),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
Ty.getNode(), Ty,
}; };
return DIVariable(MDNode::get(VMContext, &Elts[0], 6)); return DIVariable(MDNode::get(VMContext, &Elts[0], 6));
} }
@ -1083,11 +1083,11 @@ DIVariable DIFactory::CreateComplexVariable(unsigned Tag, DIDescriptor Context,
SmallVector<Value *, 9> &addr) { SmallVector<Value *, 9> &addr) {
SmallVector<Value *, 9> Elts; SmallVector<Value *, 9> Elts;
Elts.push_back(GetTagConstant(Tag)); Elts.push_back(GetTagConstant(Tag));
Elts.push_back(Context.getNode()); Elts.push_back(Context);
Elts.push_back(MDString::get(VMContext, Name)); Elts.push_back(MDString::get(VMContext, Name));
Elts.push_back(F.getNode()); Elts.push_back(F);
Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)); Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), LineNo));
Elts.push_back(Ty.getNode()); Elts.push_back(Ty);
Elts.insert(Elts.end(), addr.begin(), addr.end()); Elts.insert(Elts.end(), addr.begin(), addr.end());
return DIVariable(MDNode::get(VMContext, &Elts[0], 6+addr.size())); return DIVariable(MDNode::get(VMContext, &Elts[0], 6+addr.size()));
@ -1100,7 +1100,7 @@ DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context,
unsigned LineNo, unsigned Col) { unsigned LineNo, unsigned Col) {
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_lexical_block), GetTagConstant(dwarf::DW_TAG_lexical_block),
Context.getNode(), Context,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), Col) ConstantInt::get(Type::getInt32Ty(VMContext), Col)
}; };
@ -1114,9 +1114,9 @@ DINameSpace DIFactory::CreateNameSpace(DIDescriptor Context, StringRef Name,
unsigned LineNo) { unsigned LineNo) {
Value *Elts[] = { Value *Elts[] = {
GetTagConstant(dwarf::DW_TAG_namespace), GetTagConstant(dwarf::DW_TAG_namespace),
Context.getNode(), Context,
MDString::get(VMContext, Name), MDString::get(VMContext, Name),
F.getNode(), F,
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo) ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
}; };
return DINameSpace(MDNode::get(VMContext, &Elts[0], 5)); return DINameSpace(MDNode::get(VMContext, &Elts[0], 5));
@ -1128,8 +1128,8 @@ DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo,
Value *Elts[] = { Value *Elts[] = {
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo), ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo),
S.getNode(), S,
OrigLoc.getNode(), OrigLoc,
}; };
return DILocation(MDNode::get(VMContext, &Elts[0], 4)); return DILocation(MDNode::get(VMContext, &Elts[0], 4));
} }
@ -1140,7 +1140,7 @@ DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo,
Value *Elts[] = { Value *Elts[] = {
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo), ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo),
S.getNode(), S,
OrigLoc OrigLoc
}; };
return DILocation(MDNode::get(VMContext, &Elts[0], 4)); return DILocation(MDNode::get(VMContext, &Elts[0], 4));
@ -1154,12 +1154,12 @@ DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo,
Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
Instruction *InsertBefore) { Instruction *InsertBefore) {
assert(Storage && "no storage passed to dbg.declare"); assert(Storage && "no storage passed to dbg.declare");
assert(D.getNode() && "empty DIVariable passed to dbg.declare"); assert(D && "empty DIVariable passed to dbg.declare");
if (!DeclareFn) if (!DeclareFn)
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1),
D.getNode() }; D };
return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore); return CallInst::Create(DeclareFn, Args, Args+2, "", InsertBefore);
} }
@ -1167,12 +1167,12 @@ Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D, Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
BasicBlock *InsertAtEnd) { BasicBlock *InsertAtEnd) {
assert(Storage && "no storage passed to dbg.declare"); assert(Storage && "no storage passed to dbg.declare");
assert(D.getNode() && "empty DIVariable passed to dbg.declare"); assert(D && "empty DIVariable passed to dbg.declare");
if (!DeclareFn) if (!DeclareFn)
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1), Value *Args[] = { MDNode::get(Storage->getContext(), &Storage, 1),
D.getNode() }; D };
// If this block already has a terminator then insert this intrinsic // If this block already has a terminator then insert this intrinsic
// before the terminator. // before the terminator.
@ -1186,13 +1186,13 @@ Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
DIVariable D, DIVariable D,
Instruction *InsertBefore) { Instruction *InsertBefore) {
assert(V && "no value passed to dbg.value"); assert(V && "no value passed to dbg.value");
assert(D.getNode() && "empty DIVariable passed to dbg.value"); assert(D && "empty DIVariable passed to dbg.value");
if (!ValueFn) if (!ValueFn)
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
Value *Args[] = { MDNode::get(V->getContext(), &V, 1), Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
D.getNode() }; D };
return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore); return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
} }
@ -1201,13 +1201,13 @@ Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
DIVariable D, DIVariable D,
BasicBlock *InsertAtEnd) { BasicBlock *InsertAtEnd) {
assert(V && "no value passed to dbg.value"); assert(V && "no value passed to dbg.value");
assert(D.getNode() && "empty DIVariable passed to dbg.value"); assert(D && "empty DIVariable passed to dbg.value");
if (!ValueFn) if (!ValueFn)
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
Value *Args[] = { MDNode::get(V->getContext(), &V, 1), Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset), ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
D.getNode() }; D };
return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd); return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
} }
@ -1232,11 +1232,11 @@ void DebugInfoFinder::processModule(Module &M) {
DIDescriptor Scope(Loc.getScope(Ctx)); DIDescriptor Scope(Loc.getScope(Ctx));
if (Scope.isCompileUnit()) if (Scope.isCompileUnit())
addCompileUnit(DICompileUnit(Scope.getNode())); addCompileUnit(DICompileUnit(Scope));
else if (Scope.isSubprogram()) else if (Scope.isSubprogram())
processSubprogram(DISubprogram(Scope.getNode())); processSubprogram(DISubprogram(Scope));
else if (Scope.isLexicalBlock()) else if (Scope.isLexicalBlock())
processLexicalBlock(DILexicalBlock(Scope.getNode())); processLexicalBlock(DILexicalBlock(Scope));
if (MDNode *IA = Loc.getInlinedAt(Ctx)) if (MDNode *IA = Loc.getInlinedAt(Ctx))
processLocation(DILocation(IA)); processLocation(DILocation(IA));
@ -1258,13 +1258,13 @@ void DebugInfoFinder::processModule(Module &M) {
/// processLocation - Process DILocation. /// processLocation - Process DILocation.
void DebugInfoFinder::processLocation(DILocation Loc) { void DebugInfoFinder::processLocation(DILocation Loc) {
if (!Loc.Verify()) return; if (!Loc.Verify()) return;
DIDescriptor S(Loc.getScope().getNode()); DIDescriptor S(Loc.getScope());
if (S.isCompileUnit()) if (S.isCompileUnit())
addCompileUnit(DICompileUnit(S.getNode())); addCompileUnit(DICompileUnit(S));
else if (S.isSubprogram()) else if (S.isSubprogram())
processSubprogram(DISubprogram(S.getNode())); processSubprogram(DISubprogram(S));
else if (S.isLexicalBlock()) else if (S.isLexicalBlock())
processLexicalBlock(DILexicalBlock(S.getNode())); processLexicalBlock(DILexicalBlock(S));
processLocation(Loc.getOrigLocation()); processLocation(Loc.getOrigLocation());
} }
@ -1275,18 +1275,18 @@ void DebugInfoFinder::processType(DIType DT) {
addCompileUnit(DT.getCompileUnit()); addCompileUnit(DT.getCompileUnit());
if (DT.isCompositeType()) { if (DT.isCompositeType()) {
DICompositeType DCT(DT.getNode()); DICompositeType DCT(DT);
processType(DCT.getTypeDerivedFrom()); processType(DCT.getTypeDerivedFrom());
DIArray DA = DCT.getTypeArray(); DIArray DA = DCT.getTypeArray();
for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) { for (unsigned i = 0, e = DA.getNumElements(); i != e; ++i) {
DIDescriptor D = DA.getElement(i); DIDescriptor D = DA.getElement(i);
if (D.isType()) if (D.isType())
processType(DIType(D.getNode())); processType(DIType(D));
else if (D.isSubprogram()) else if (D.isSubprogram())
processSubprogram(DISubprogram(D.getNode())); processSubprogram(DISubprogram(D));
} }
} else if (DT.isDerivedType()) { } else if (DT.isDerivedType()) {
DIDerivedType DDT(DT.getNode()); DIDerivedType DDT(DT);
processType(DDT.getTypeDerivedFrom()); processType(DDT.getTypeDerivedFrom());
} }
} }
@ -1295,9 +1295,9 @@ void DebugInfoFinder::processType(DIType DT) {
void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) { void DebugInfoFinder::processLexicalBlock(DILexicalBlock LB) {
DIScope Context = LB.getContext(); DIScope Context = LB.getContext();
if (Context.isLexicalBlock()) if (Context.isLexicalBlock())
return processLexicalBlock(DILexicalBlock(Context.getNode())); return processLexicalBlock(DILexicalBlock(Context));
else else
return processSubprogram(DISubprogram(Context.getNode())); return processSubprogram(DISubprogram(Context));
} }
/// processSubprogram - Process DISubprogram. /// processSubprogram - Process DISubprogram.
@ -1317,7 +1317,7 @@ void DebugInfoFinder::processDeclare(DbgDeclareInst *DDI) {
if (!DV.isVariable()) if (!DV.isVariable())
return; return;
if (!NodesSeen.insert(DV.getNode())) if (!NodesSeen.insert(DV))
return; return;
addCompileUnit(DIVariable(N).getCompileUnit()); addCompileUnit(DIVariable(N).getCompileUnit());
@ -1329,10 +1329,10 @@ bool DebugInfoFinder::addType(DIType DT) {
if (!DT.isValid()) if (!DT.isValid())
return false; return false;
if (!NodesSeen.insert(DT.getNode())) if (!NodesSeen.insert(DT))
return false; return false;
TYs.push_back(DT.getNode()); TYs.push_back(DT);
return true; return true;
} }
@ -1341,34 +1341,34 @@ bool DebugInfoFinder::addCompileUnit(DICompileUnit CU) {
if (!CU.Verify()) if (!CU.Verify())
return false; return false;
if (!NodesSeen.insert(CU.getNode())) if (!NodesSeen.insert(CU))
return false; return false;
CUs.push_back(CU.getNode()); CUs.push_back(CU);
return true; return true;
} }
/// addGlobalVariable - Add global variable into GVs. /// addGlobalVariable - Add global variable into GVs.
bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) { bool DebugInfoFinder::addGlobalVariable(DIGlobalVariable DIG) {
if (!DIDescriptor(DIG.getNode()).isGlobalVariable()) if (!DIDescriptor(DIG).isGlobalVariable())
return false; return false;
if (!NodesSeen.insert(DIG.getNode())) if (!NodesSeen.insert(DIG))
return false; return false;
GVs.push_back(DIG.getNode()); GVs.push_back(DIG);
return true; return true;
} }
// addSubprogram - Add subprgoram into SPs. // addSubprogram - Add subprgoram into SPs.
bool DebugInfoFinder::addSubprogram(DISubprogram SP) { bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
if (!DIDescriptor(SP.getNode()).isSubprogram()) if (!DIDescriptor(SP).isSubprogram())
return false; return false;
if (!NodesSeen.insert(SP.getNode())) if (!NodesSeen.insert(SP))
return false; return false;
SPs.push_back(SP.getNode()); SPs.push_back(SP);
return true; return true;
} }
@ -1383,8 +1383,8 @@ static Value *findDbgGlobalDeclare(GlobalVariable *V) {
DIDescriptor DIG(cast_or_null<MDNode>(NMD->getOperand(i))); DIDescriptor DIG(cast_or_null<MDNode>(NMD->getOperand(i)));
if (!DIG.isGlobalVariable()) if (!DIG.isGlobalVariable())
continue; continue;
if (DIGlobalVariable(DIG.getNode()).getGlobal() == V) if (DIGlobalVariable(DIG).getGlobal() == V)
return DIG.getNode(); return DIG;
} }
return 0; return 0;
} }
@ -1462,7 +1462,7 @@ DISubprogram llvm::getDISubprogram(MDNode *Scope) {
return DISubprogram(Scope); return DISubprogram(Scope);
if (D.isLexicalBlock()) if (D.isLexicalBlock())
return getDISubprogram(DILexicalBlock(Scope).getContext().getNode()); return getDISubprogram(DILexicalBlock(Scope).getContext());
return DISubprogram(); return DISubprogram();
} }
@ -1470,10 +1470,10 @@ DISubprogram llvm::getDISubprogram(MDNode *Scope) {
/// getDICompositeType - Find underlying composite type. /// getDICompositeType - Find underlying composite type.
DICompositeType llvm::getDICompositeType(DIType T) { DICompositeType llvm::getDICompositeType(DIType T) {
if (T.isCompositeType()) if (T.isCompositeType())
return DICompositeType(T.getNode()); return DICompositeType(T);
if (T.isDerivedType()) if (T.isDerivedType())
return getDICompositeType(DIDerivedType(T.getNode()).getTypeDerivedFrom()); return getDICompositeType(DIDerivedType(T).getTypeDerivedFrom());
return DICompositeType(); return DICompositeType();
} }

View File

@ -509,7 +509,7 @@ static bool EmitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
// cast away const; DIetc do not take const operands for some reason. // cast away const; DIetc do not take const operands for some reason.
DIVariable V(const_cast<MDNode*>(MI->getOperand(2).getMetadata())); DIVariable V(const_cast<MDNode*>(MI->getOperand(2).getMetadata()));
if (V.getContext().isSubprogram()) if (V.getContext().isSubprogram())
OS << DISubprogram(V.getContext().getNode()).getDisplayName() << ":"; OS << DISubprogram(V.getContext()).getDisplayName() << ":";
OS << V.getName() << " <- "; OS << V.getName() << " <- ";
// Register or immediate value. Register 0 means undef. // Register or immediate value. Register 0 means undef.

View File

@ -232,7 +232,7 @@ public:
void setParent(DbgScope *P) { Parent = P; } void setParent(DbgScope *P) { Parent = P; }
DIDescriptor getDesc() const { return Desc; } DIDescriptor getDesc() const { return Desc; }
MDNode *getInlinedAt() const { return InlinedAtLocation; } MDNode *getInlinedAt() const { return InlinedAtLocation; }
MDNode *getScopeNode() const { return Desc.getNode(); } MDNode *getScopeNode() const { return Desc; }
const SmallVector<DbgScope *, 4> &getScopes() { return Scopes; } const SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
const SmallVector<DbgVariable *, 8> &getVariables() { return Variables; } const SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
const SmallVector<DbgRange, 4> &getRanges() { return Ranges; } const SmallVector<DbgRange, 4> &getRanges() { return Ranges; }
@ -304,7 +304,7 @@ public:
void DbgScope::dump() const { void DbgScope::dump() const {
raw_ostream &err = dbgs(); raw_ostream &err = dbgs();
err.indent(IndentLevel); err.indent(IndentLevel);
MDNode *N = Desc.getNode(); MDNode *N = Desc;
N->dump(); N->dump();
if (AbstractScope) if (AbstractScope)
err << "Abstract Scope\n"; err << "Abstract Scope\n";
@ -564,16 +564,16 @@ DIType DwarfDebug::getBlockByrefType(DIType Ty, std::string Name) {
unsigned tag = Ty.getTag(); unsigned tag = Ty.getTag();
if (tag == dwarf::DW_TAG_pointer_type) { if (tag == dwarf::DW_TAG_pointer_type) {
DIDerivedType DTy = DIDerivedType(Ty.getNode()); DIDerivedType DTy = DIDerivedType(Ty);
subType = DTy.getTypeDerivedFrom(); subType = DTy.getTypeDerivedFrom();
} }
DICompositeType blockStruct = DICompositeType(subType.getNode()); DICompositeType blockStruct = DICompositeType(subType);
DIArray Elements = blockStruct.getTypeArray(); DIArray Elements = blockStruct.getTypeArray();
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Element = Elements.getElement(i); DIDescriptor Element = Elements.getElement(i);
DIDerivedType DT = DIDerivedType(Element.getNode()); DIDerivedType DT = DIDerivedType(Element);
if (Name == DT.getName()) if (Name == DT.getName())
return (DT.getTypeDerivedFrom()); return (DT.getTypeDerivedFrom());
} }
@ -704,12 +704,12 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die,
StringRef varName = VD.getName(); StringRef varName = VD.getName();
if (Tag == dwarf::DW_TAG_pointer_type) { if (Tag == dwarf::DW_TAG_pointer_type) {
DIDerivedType DTy = DIDerivedType(Ty.getNode()); DIDerivedType DTy = DIDerivedType(Ty);
TmpTy = DTy.getTypeDerivedFrom(); TmpTy = DTy.getTypeDerivedFrom();
isPointer = true; isPointer = true;
} }
DICompositeType blockStruct = DICompositeType(TmpTy.getNode()); DICompositeType blockStruct = DICompositeType(TmpTy);
// Find the __forwarding field and the variable field in the __Block_byref // Find the __forwarding field and the variable field in the __Block_byref
// struct. // struct.
@ -719,7 +719,7 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die,
for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) { for (unsigned i = 0, N = Fields.getNumElements(); i < N; ++i) {
DIDescriptor Element = Fields.getElement(i); DIDescriptor Element = Fields.getElement(i);
DIDerivedType DT = DIDerivedType(Element.getNode()); DIDerivedType DT = DIDerivedType(Element);
StringRef fieldName = DT.getName(); StringRef fieldName = DT.getName();
if (fieldName == "__forwarding") if (fieldName == "__forwarding")
forwardingField = Element; forwardingField = Element;
@ -729,9 +729,9 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die,
// Get the offsets for the forwarding field and the variable field. // Get the offsets for the forwarding field and the variable field.
unsigned forwardingFieldOffset = unsigned forwardingFieldOffset =
DIDerivedType(forwardingField.getNode()).getOffsetInBits() >> 3; DIDerivedType(forwardingField).getOffsetInBits() >> 3;
unsigned varFieldOffset = unsigned varFieldOffset =
DIDerivedType(varField.getNode()).getOffsetInBits() >> 3; DIDerivedType(varField).getOffsetInBits() >> 3;
// Decode the original location, and use that as the start of the byref // Decode the original location, and use that as the start of the byref
// variable's location. // variable's location.
@ -877,12 +877,12 @@ bool DwarfDebug::addConstantFPValue(DIE *Die, DbgVariable *DV,
/// addToContextOwner - Add Die into the list of its context owner's children. /// addToContextOwner - Add Die into the list of its context owner's children.
void DwarfDebug::addToContextOwner(DIE *Die, DIDescriptor Context) { void DwarfDebug::addToContextOwner(DIE *Die, DIDescriptor Context) {
if (Context.isType()) { if (Context.isType()) {
DIE *ContextDIE = getOrCreateTypeDIE(DIType(Context.getNode())); DIE *ContextDIE = getOrCreateTypeDIE(DIType(Context));
ContextDIE->addChild(Die); ContextDIE->addChild(Die);
} else if (Context.isNameSpace()) { } else if (Context.isNameSpace()) {
DIE *ContextDIE = getOrCreateNameSpace(DINameSpace(Context.getNode())); DIE *ContextDIE = getOrCreateNameSpace(DINameSpace(Context));
ContextDIE->addChild(Die); ContextDIE->addChild(Die);
} else if (DIE *ContextDIE = ModuleCU->getDIE(Context.getNode())) } else if (DIE *ContextDIE = ModuleCU->getDIE(Context))
ContextDIE->addChild(Die); ContextDIE->addChild(Die);
else else
ModuleCU->addDie(Die); ModuleCU->addDie(Die);
@ -891,20 +891,20 @@ void DwarfDebug::addToContextOwner(DIE *Die, DIDescriptor Context) {
/// getOrCreateTypeDIE - Find existing DIE or create new DIE for the /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
/// given DIType. /// given DIType.
DIE *DwarfDebug::getOrCreateTypeDIE(DIType Ty) { DIE *DwarfDebug::getOrCreateTypeDIE(DIType Ty) {
DIE *TyDIE = ModuleCU->getDIE(Ty.getNode()); DIE *TyDIE = ModuleCU->getDIE(Ty);
if (TyDIE) if (TyDIE)
return TyDIE; return TyDIE;
// Create new type. // Create new type.
TyDIE = new DIE(dwarf::DW_TAG_base_type); TyDIE = new DIE(dwarf::DW_TAG_base_type);
ModuleCU->insertDIE(Ty.getNode(), TyDIE); ModuleCU->insertDIE(Ty, TyDIE);
if (Ty.isBasicType()) if (Ty.isBasicType())
constructTypeDIE(*TyDIE, DIBasicType(Ty.getNode())); constructTypeDIE(*TyDIE, DIBasicType(Ty));
else if (Ty.isCompositeType()) else if (Ty.isCompositeType())
constructTypeDIE(*TyDIE, DICompositeType(Ty.getNode())); constructTypeDIE(*TyDIE, DICompositeType(Ty));
else { else {
assert(Ty.isDerivedType() && "Unknown kind of DIType"); assert(Ty.isDerivedType() && "Unknown kind of DIType");
constructTypeDIE(*TyDIE, DIDerivedType(Ty.getNode())); constructTypeDIE(*TyDIE, DIDerivedType(Ty));
} }
addToContextOwner(TyDIE, Ty.getContext()); addToContextOwner(TyDIE, Ty.getContext());
@ -917,7 +917,7 @@ void DwarfDebug::addType(DIE *Entity, DIType Ty) {
return; return;
// Check for pre-existence. // Check for pre-existence.
DIEEntry *Entry = ModuleCU->getDIEEntry(Ty.getNode()); DIEEntry *Entry = ModuleCU->getDIEEntry(Ty);
// If it exists then use the existing value. // If it exists then use the existing value.
if (Entry) { if (Entry) {
Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry); Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry);
@ -929,7 +929,7 @@ void DwarfDebug::addType(DIE *Entity, DIType Ty) {
// Set up proxy. // Set up proxy.
Entry = createDIEEntry(Buffer); Entry = createDIEEntry(Buffer);
ModuleCU->insertDIEEntry(Ty.getNode(), Entry); ModuleCU->insertDIEEntry(Ty, Entry);
Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry); Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry);
} }
@ -998,9 +998,9 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
// Add enumerators to enumeration type. // Add enumerators to enumeration type.
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIE *ElemDie = NULL; DIE *ElemDie = NULL;
DIDescriptor Enum(Elements.getElement(i).getNode()); DIDescriptor Enum(Elements.getElement(i));
if (Enum.isEnumerator()) { if (Enum.isEnumerator()) {
ElemDie = constructEnumTypeDIE(DIEnumerator(Enum.getNode())); ElemDie = constructEnumTypeDIE(DIEnumerator(Enum));
Buffer.addChild(ElemDie); Buffer.addChild(ElemDie);
} }
} }
@ -1010,7 +1010,7 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
// Add return type. // Add return type.
DIArray Elements = CTy.getTypeArray(); DIArray Elements = CTy.getTypeArray();
DIDescriptor RTy = Elements.getElement(0); DIDescriptor RTy = Elements.getElement(0);
addType(&Buffer, DIType(RTy.getNode())); addType(&Buffer, DIType(RTy));
// Add prototype flag. // Add prototype flag.
addUInt(&Buffer, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1); addUInt(&Buffer, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1);
@ -1019,7 +1019,7 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) { for (unsigned i = 1, N = Elements.getNumElements(); i < N; ++i) {
DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter); DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
DIDescriptor Ty = Elements.getElement(i); DIDescriptor Ty = Elements.getElement(i);
addType(Arg, DIType(Ty.getNode())); addType(Arg, DIType(Ty));
Buffer.addChild(Arg); Buffer.addChild(Arg);
} }
} }
@ -1040,9 +1040,9 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
DIDescriptor Element = Elements.getElement(i); DIDescriptor Element = Elements.getElement(i);
DIE *ElemDie = NULL; DIE *ElemDie = NULL;
if (Element.isSubprogram()) if (Element.isSubprogram())
ElemDie = createSubprogramDIE(DISubprogram(Element.getNode())); ElemDie = createSubprogramDIE(DISubprogram(Element));
else if (Element.isVariable()) { else if (Element.isVariable()) {
DIVariable DV(Element.getNode()); DIVariable DV(Element);
ElemDie = new DIE(dwarf::DW_TAG_variable); ElemDie = new DIE(dwarf::DW_TAG_variable);
addString(ElemDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, addString(ElemDie, dwarf::DW_AT_name, dwarf::DW_FORM_string,
DV.getName()); DV.getName());
@ -1051,7 +1051,7 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
addUInt(ElemDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); addUInt(ElemDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1);
addSourceLine(ElemDie, &DV); addSourceLine(ElemDie, &DV);
} else if (Element.isDerivedType()) } else if (Element.isDerivedType())
ElemDie = createMemberDIE(DIDerivedType(Element.getNode())); ElemDie = createMemberDIE(DIDerivedType(Element));
else else
continue; continue;
Buffer.addChild(ElemDie); Buffer.addChild(ElemDie);
@ -1066,9 +1066,9 @@ void DwarfDebug::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
dwarf::DW_FORM_data1, RLang); dwarf::DW_FORM_data1, RLang);
DICompositeType ContainingType = CTy.getContainingType(); DICompositeType ContainingType = CTy.getContainingType();
if (DIDescriptor(ContainingType.getNode()).isCompositeType()) if (DIDescriptor(ContainingType).isCompositeType())
addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4,
getOrCreateTypeDIE(DIType(ContainingType.getNode()))); getOrCreateTypeDIE(DIType(ContainingType)));
break; break;
} }
default: default:
@ -1139,7 +1139,7 @@ void DwarfDebug::constructArrayTypeDIE(DIE &Buffer,
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Element = Elements.getElement(i); DIDescriptor Element = Elements.getElement(i);
if (Element.getTag() == dwarf::DW_TAG_subrange_type) if (Element.getTag() == dwarf::DW_TAG_subrange_type)
constructSubrangeDIE(Buffer, DISubrange(Element.getNode()), IdxTy); constructSubrangeDIE(Buffer, DISubrange(Element), IdxTy);
} }
} }
@ -1266,7 +1266,7 @@ DIE *DwarfDebug::createMemberDIE(const DIDerivedType &DT) {
/// createSubprogramDIE - Create new DIE using SP. /// createSubprogramDIE - Create new DIE using SP.
DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) { DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
DIE *SPDie = ModuleCU->getDIE(SP.getNode()); DIE *SPDie = ModuleCU->getDIE(SP);
if (SPDie) if (SPDie)
return SPDie; return SPDie;
@ -1296,7 +1296,7 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
if (Args.getNumElements() == 0 || SPTag != dwarf::DW_TAG_subroutine_type) if (Args.getNumElements() == 0 || SPTag != dwarf::DW_TAG_subroutine_type)
addType(SPDie, SPTy); addType(SPDie, SPTy);
else else
addType(SPDie, DIType(Args.getElement(0).getNode())); addType(SPDie, DIType(Args.getElement(0)));
unsigned VK = SP.getVirtuality(); unsigned VK = SP.getVirtuality();
if (VK) { if (VK) {
@ -1306,7 +1306,7 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
addUInt(Block, 0, dwarf::DW_FORM_data1, SP.getVirtualIndex()); addUInt(Block, 0, dwarf::DW_FORM_data1, SP.getVirtualIndex());
addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, 0, Block); addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, 0, Block);
ContainingTypeMap.insert(std::make_pair(SPDie, ContainingTypeMap.insert(std::make_pair(SPDie,
SP.getContainingType().getNode())); SP.getContainingType()));
} }
if (MakeDecl || !SP.isDefinition()) { if (MakeDecl || !SP.isDefinition()) {
@ -1321,7 +1321,7 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
if (SPTag == dwarf::DW_TAG_subroutine_type) if (SPTag == dwarf::DW_TAG_subroutine_type)
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter); DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
DIType ATy = DIType(DIType(Args.getElement(i).getNode())); DIType ATy = DIType(DIType(Args.getElement(i)));
addType(Arg, ATy); addType(Arg, ATy);
if (ATy.isArtificial()) if (ATy.isArtificial())
addUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); addUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1);
@ -1339,7 +1339,7 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
addUInt(SPDie, dwarf::DW_AT_APPLE_optimized, dwarf::DW_FORM_flag, 1); addUInt(SPDie, dwarf::DW_AT_APPLE_optimized, dwarf::DW_FORM_flag, 1);
// DW_TAG_inlined_subroutine may refer to this DIE. // DW_TAG_inlined_subroutine may refer to this DIE.
ModuleCU->insertDIE(SP.getNode(), SPDie); ModuleCU->insertDIE(SP, SPDie);
return SPDie; return SPDie;
} }
@ -1357,7 +1357,7 @@ DbgScope *DwarfDebug::getOrCreateAbstractScope(MDNode *N) {
if (Scope.isLexicalBlock()) { if (Scope.isLexicalBlock()) {
DILexicalBlock DB(N); DILexicalBlock DB(N);
DIDescriptor ParentDesc = DB.getContext(); DIDescriptor ParentDesc = DB.getContext();
Parent = getOrCreateAbstractScope(ParentDesc.getNode()); Parent = getOrCreateAbstractScope(ParentDesc);
} }
AScope = new DbgScope(Parent, DIDescriptor(N), NULL); AScope = new DbgScope(Parent, DIDescriptor(N), NULL);
@ -1380,7 +1380,7 @@ static bool isSubprogramContext(MDNode *Context) {
if (D.isSubprogram()) if (D.isSubprogram())
return true; return true;
if (D.isType()) if (D.isType())
return isSubprogramContext(DIType(Context).getContext().getNode()); return isSubprogramContext(DIType(Context).getContext());
return false; return false;
} }
@ -1400,7 +1400,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(MDNode *SPNode) {
// specification DIE for a function defined inside a function. // specification DIE for a function defined inside a function.
if (SP.isDefinition() && !SP.getContext().isCompileUnit() && if (SP.isDefinition() && !SP.getContext().isCompileUnit() &&
!SP.getContext().isFile() && !SP.getContext().isFile() &&
!isSubprogramContext(SP.getContext().getNode())) { !isSubprogramContext(SP.getContext())) {
addUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); addUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
// Add arguments. // Add arguments.
@ -1410,7 +1410,7 @@ DIE *DwarfDebug::updateSubprogramScopeDIE(MDNode *SPNode) {
if (SPTag == dwarf::DW_TAG_subroutine_type) if (SPTag == dwarf::DW_TAG_subroutine_type)
for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) {
DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter); DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter);
DIType ATy = DIType(DIType(Args.getElement(i).getNode())); DIType ATy = DIType(DIType(Args.getElement(i)));
addType(Arg, ATy); addType(Arg, ATy);
if (ATy.isArtificial()) if (ATy.isArtificial())
addUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); addUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1);
@ -1508,8 +1508,8 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
DIScope DS(Scope->getScopeNode()); DIScope DS(Scope->getScopeNode());
DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine); DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine);
DISubprogram InlinedSP = getDISubprogram(DS.getNode()); DISubprogram InlinedSP = getDISubprogram(DS);
DIE *OriginDIE = ModuleCU->getDIE(InlinedSP.getNode()); DIE *OriginDIE = ModuleCU->getDIE(InlinedSP);
assert(OriginDIE && "Unable to find Origin DIE!"); assert(OriginDIE && "Unable to find Origin DIE!");
addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin,
dwarf::DW_FORM_ref4, OriginDIE); dwarf::DW_FORM_ref4, OriginDIE);
@ -1521,12 +1521,12 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
// Track the start label for this inlined function. // Track the start label for this inlined function.
DenseMap<MDNode *, SmallVector<InlineInfoLabels, 4> >::iterator DenseMap<MDNode *, SmallVector<InlineInfoLabels, 4> >::iterator
I = InlineInfo.find(InlinedSP.getNode()); I = InlineInfo.find(InlinedSP);
if (I == InlineInfo.end()) { if (I == InlineInfo.end()) {
InlineInfo[InlinedSP.getNode()].push_back(std::make_pair(StartLabel, InlineInfo[InlinedSP].push_back(std::make_pair(StartLabel,
ScopeDIE)); ScopeDIE));
InlinedSPNodes.push_back(InlinedSP.getNode()); InlinedSPNodes.push_back(InlinedSP);
} else } else
I->second.push_back(std::make_pair(StartLabel, ScopeDIE)); I->second.push_back(std::make_pair(StartLabel, ScopeDIE));
@ -1571,8 +1571,8 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, DbgScope *Scope) {
if (AbsDIE) { if (AbsDIE) {
DIScope DS(Scope->getScopeNode()); DIScope DS(Scope->getScopeNode());
DISubprogram InlinedSP = getDISubprogram(DS.getNode()); DISubprogram InlinedSP = getDISubprogram(DS);
DIE *OriginSPDIE = ModuleCU->getDIE(InlinedSP.getNode()); DIE *OriginSPDIE = ModuleCU->getDIE(InlinedSP);
(void) OriginSPDIE; (void) OriginSPDIE;
assert(OriginSPDIE && "Unable to find Origin DIE for the SP!"); assert(OriginSPDIE && "Unable to find Origin DIE for the SP!");
DIE *AbsDIE = DV->getAbstractVariable()->getDIE(); DIE *AbsDIE = DV->getAbstractVariable()->getDIE();
@ -1655,13 +1655,13 @@ void DwarfDebug::addPubTypes(DISubprogram SP) {
DIArray Args = SPTy.getTypeArray(); DIArray Args = SPTy.getTypeArray();
for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) { for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) {
DIType ATy(Args.getElement(i).getNode()); DIType ATy(Args.getElement(i));
if (!ATy.isValid()) if (!ATy.isValid())
continue; continue;
DICompositeType CATy = getDICompositeType(ATy); DICompositeType CATy = getDICompositeType(ATy);
if (DIDescriptor(CATy.getNode()).Verify() && !CATy.getName().empty() if (DIDescriptor(CATy).Verify() && !CATy.getName().empty()
&& !CATy.isForwardDecl()) { && !CATy.isForwardDecl()) {
if (DIEEntry *Entry = ModuleCU->getDIEEntry(CATy.getNode())) if (DIEEntry *Entry = ModuleCU->getDIEEntry(CATy))
ModuleCU->addGlobalType(CATy.getName(), Entry->getEntry()); ModuleCU->addGlobalType(CATy.getName(), Entry->getEntry());
} }
} }
@ -1678,9 +1678,9 @@ DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) {
ScopeDIE = constructInlinedScopeDIE(Scope); ScopeDIE = constructInlinedScopeDIE(Scope);
else if (DS.isSubprogram()) { else if (DS.isSubprogram()) {
if (Scope->isAbstractScope()) if (Scope->isAbstractScope())
ScopeDIE = ModuleCU->getDIE(DS.getNode()); ScopeDIE = ModuleCU->getDIE(DS);
else else
ScopeDIE = updateSubprogramScopeDIE(DS.getNode()); ScopeDIE = updateSubprogramScopeDIE(DS);
} }
else else
ScopeDIE = constructLexicalScopeDIE(Scope); ScopeDIE = constructLexicalScopeDIE(Scope);
@ -1704,7 +1704,7 @@ DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) {
} }
if (DS.isSubprogram()) if (DS.isSubprogram())
addPubTypes(DISubprogram(DS.getNode())); addPubTypes(DISubprogram(DS));
return ScopeDIE; return ScopeDIE;
} }
@ -1748,11 +1748,11 @@ unsigned DwarfDebug::GetOrCreateSourceID(StringRef DirName, StringRef FileName){
/// getOrCreateNameSpace - Create a DIE for DINameSpace. /// getOrCreateNameSpace - Create a DIE for DINameSpace.
DIE *DwarfDebug::getOrCreateNameSpace(DINameSpace NS) { DIE *DwarfDebug::getOrCreateNameSpace(DINameSpace NS) {
DIE *NDie = ModuleCU->getDIE(NS.getNode()); DIE *NDie = ModuleCU->getDIE(NS);
if (NDie) if (NDie)
return NDie; return NDie;
NDie = new DIE(dwarf::DW_TAG_namespace); NDie = new DIE(dwarf::DW_TAG_namespace);
ModuleCU->insertDIE(NS.getNode(), NDie); ModuleCU->insertDIE(NS, NDie);
if (!NS.getName().empty()) if (!NS.getName().empty())
addString(NDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, NS.getName()); addString(NDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, NS.getName());
addSourceLine(NDie, &NS); addSourceLine(NDie, &NS);
@ -1811,7 +1811,7 @@ void DwarfDebug::constructGlobalVariableDIE(MDNode *N) {
return; return;
// Check for pre-existence. // Check for pre-existence.
if (ModuleCU->getDIE(DI_GV.getNode())) if (ModuleCU->getDIE(DI_GV))
return; return;
DIE *VariableDie = createGlobalVariableDIE(DI_GV); DIE *VariableDie = createGlobalVariableDIE(DI_GV);
@ -1827,7 +1827,7 @@ void DwarfDebug::constructGlobalVariableDIE(MDNode *N) {
// or a subprogram. // or a subprogram.
if (DI_GV.isDefinition() && !GVContext.isCompileUnit() && if (DI_GV.isDefinition() && !GVContext.isCompileUnit() &&
!GVContext.isFile() && !GVContext.isFile() &&
!isSubprogramContext(GVContext.getNode())) { !isSubprogramContext(GVContext)) {
// Create specification DIE. // Create specification DIE.
DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable);
addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification,
@ -1854,7 +1854,7 @@ void DwarfDebug::constructGlobalVariableDIE(MDNode *N) {
DIType GTy = DI_GV.getType(); DIType GTy = DI_GV.getType();
if (GTy.isCompositeType() && !GTy.getName().empty() if (GTy.isCompositeType() && !GTy.getName().empty()
&& !GTy.isForwardDecl()) { && !GTy.isForwardDecl()) {
DIEEntry *Entry = ModuleCU->getDIEEntry(GTy.getNode()); DIEEntry *Entry = ModuleCU->getDIEEntry(GTy);
assert(Entry && "Missing global type!"); assert(Entry && "Missing global type!");
ModuleCU->addGlobalType(GTy.getName(), Entry->getEntry()); ModuleCU->addGlobalType(GTy.getName(), Entry->getEntry());
} }
@ -2040,11 +2040,11 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var,
unsigned FrameIdx, unsigned FrameIdx,
DebugLoc ScopeLoc) { DebugLoc ScopeLoc) {
DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var.getNode()); DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var);
if (AbsDbgVariable) if (AbsDbgVariable)
return AbsDbgVariable; return AbsDbgVariable;
LLVMContext &Ctx = Var.getNode()->getContext(); LLVMContext &Ctx = Var->getContext();
DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx)); DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx));
if (!Scope) if (!Scope)
return NULL; return NULL;
@ -2052,7 +2052,7 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var,
AbsDbgVariable = new DbgVariable(Var, FrameIdx, AbsDbgVariable = new DbgVariable(Var, FrameIdx,
NULL /* No more-abstract variable*/); NULL /* No more-abstract variable*/);
Scope->addVariable(AbsDbgVariable); Scope->addVariable(AbsDbgVariable);
AbstractVariables[Var.getNode()] = AbsDbgVariable; AbstractVariables[Var] = AbsDbgVariable;
return AbsDbgVariable; return AbsDbgVariable;
} }
@ -2062,11 +2062,11 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var,
const MachineInstr *MI, const MachineInstr *MI,
DebugLoc ScopeLoc) { DebugLoc ScopeLoc) {
DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var.getNode()); DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var);
if (AbsDbgVariable) if (AbsDbgVariable)
return AbsDbgVariable; return AbsDbgVariable;
LLVMContext &Ctx = Var.getNode()->getContext(); LLVMContext &Ctx = Var->getContext();
DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx)); DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx));
if (!Scope) if (!Scope)
return NULL; return NULL;
@ -2074,7 +2074,7 @@ DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var,
AbsDbgVariable = new DbgVariable(Var, MI, AbsDbgVariable = new DbgVariable(Var, MI,
NULL /* No more-abstract variable*/); NULL /* No more-abstract variable*/);
Scope->addVariable(AbsDbgVariable); Scope->addVariable(AbsDbgVariable);
AbstractVariables[Var.getNode()] = AbsDbgVariable; AbstractVariables[Var] = AbsDbgVariable;
DbgValueStartMap[MI] = AbsDbgVariable; DbgValueStartMap[MI] = AbsDbgVariable;
return AbsDbgVariable; return AbsDbgVariable;
} }
@ -2236,7 +2236,7 @@ DbgScope *DwarfDebug::getOrCreateDbgScope(MDNode *Scope, MDNode *InlinedAt) {
DbgScopeMap.insert(std::make_pair(Scope, WScope)); DbgScopeMap.insert(std::make_pair(Scope, WScope));
if (DIDescriptor(Scope).isLexicalBlock()) { if (DIDescriptor(Scope).isLexicalBlock()) {
DbgScope *Parent = DbgScope *Parent =
getOrCreateDbgScope(DILexicalBlock(Scope).getContext().getNode(), NULL); getOrCreateDbgScope(DILexicalBlock(Scope).getContext(), NULL);
WScope->setParent(Parent); WScope->setParent(Parent);
Parent->addScope(WScope); Parent->addScope(WScope);
} }
@ -2258,7 +2258,7 @@ DbgScope *DwarfDebug::getOrCreateDbgScope(MDNode *Scope, MDNode *InlinedAt) {
DbgScopeMap.insert(std::make_pair(InlinedAt, WScope)); DbgScopeMap.insert(std::make_pair(InlinedAt, WScope));
DILocation DL(InlinedAt); DILocation DL(InlinedAt);
DbgScope *Parent = DbgScope *Parent =
getOrCreateDbgScope(DL.getScope().getNode(), DL.getOrigLocation().getNode()); getOrCreateDbgScope(DL.getScope(), DL.getOrigLocation());
WScope->setParent(Parent); WScope->setParent(Parent);
Parent->addScope(WScope); Parent->addScope(WScope);