Wrap const MDNode * inside DIDescriptor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103295 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel 2010-05-07 20:54:48 +00:00
parent 735538b3eb
commit e9f8f5e600
5 changed files with 94 additions and 91 deletions

View File

@ -41,7 +41,7 @@ namespace llvm {
/// change in certain situations.
class DIDescriptor {
protected:
MDNode *DbgNode;
const MDNode *DbgNode;
StringRef getStringField(unsigned Elt) const;
unsigned getUnsignedField(unsigned Elt) const {
@ -59,12 +59,13 @@ namespace llvm {
public:
explicit DIDescriptor() : DbgNode(0) {}
explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
explicit DIDescriptor(const MDNode *N) : DbgNode(N) {}
bool Verify() const { return DbgNode != 0; }
operator MDNode *() const { return DbgNode; }
MDNode *operator ->() const { return DbgNode; }
operator const MDNode *() const { return DbgNode; }
operator MDNode *() const { return const_cast<MDNode*>(DbgNode); }
MDNode *operator ->() const { return const_cast<MDNode*>(DbgNode); }
unsigned getVersion() const {
return getUnsignedField(0) & LLVMDebugVersionMask;
@ -75,7 +76,7 @@ namespace llvm {
}
/// ValidDebugInfo - Return true if N represents valid debug info value.
static bool ValidDebugInfo(MDNode *N, unsigned OptLevel);
static bool ValidDebugInfo(const MDNode *N, unsigned OptLevel);
/// print - print descriptor.
void print(raw_ostream &OS) const;
@ -103,7 +104,7 @@ namespace llvm {
/// DISubrange - This is used to represent ranges, for array bounds.
class DISubrange : public DIDescriptor {
public:
explicit DISubrange(MDNode *N = 0) : DIDescriptor(N) {}
explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {}
int64_t getLo() const { return (int64_t)getUInt64Field(1); }
int64_t getHi() const { return (int64_t)getUInt64Field(2); }
@ -112,7 +113,7 @@ namespace llvm {
/// DIArray - This descriptor holds an array of descriptors.
class DIArray : public DIDescriptor {
public:
explicit DIArray(MDNode *N = 0)
explicit DIArray(const MDNode *N = 0)
: DIDescriptor(N) {}
unsigned getNumElements() const;
@ -124,7 +125,7 @@ namespace llvm {
/// DIScope - A base class for various scopes.
class DIScope : public DIDescriptor {
public:
explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {}
explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {}
virtual ~DIScope() {}
StringRef getFilename() const;
@ -134,7 +135,7 @@ namespace llvm {
/// DICompileUnit - A wrapper for a compile unit.
class DICompileUnit : public DIScope {
public:
explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {}
explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {}
unsigned getLanguage() const { return getUnsignedField(2); }
StringRef getFilename() const { return getStringField(3); }
@ -168,7 +169,7 @@ namespace llvm {
/// DIFile - This is a wrapper for a file.
class DIFile : public DIScope {
public:
explicit DIFile(MDNode *N = 0) : DIScope(N) {
explicit DIFile(const MDNode *N = 0) : DIScope(N) {
if (DbgNode && !isFile())
DbgNode = 0;
}
@ -182,7 +183,7 @@ namespace llvm {
/// type/precision or a file/line pair for location info.
class DIEnumerator : public DIDescriptor {
public:
explicit DIEnumerator(MDNode *N = 0) : DIDescriptor(N) {}
explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {}
StringRef getName() const { return getStringField(1); }
uint64_t getEnumValue() const { return getUInt64Field(2); }
@ -207,14 +208,14 @@ namespace llvm {
protected:
// This ctor is used when the Tag has already been validated by a derived
// ctor.
DIType(MDNode *N, bool, bool) : DIScope(N) {}
DIType(const MDNode *N, bool, bool) : DIScope(N) {}
public:
/// Verify - Verify that a type descriptor is well formed.
bool Verify() const;
public:
explicit DIType(MDNode *N);
explicit DIType(const MDNode *N);
explicit DIType() {}
virtual ~DIType() {}
@ -272,7 +273,7 @@ namespace llvm {
/// DIBasicType - A basic type, like 'int' or 'float'.
class DIBasicType : public DIType {
public:
explicit DIBasicType(MDNode *N = 0) : DIType(N) {}
explicit DIBasicType(const MDNode *N = 0) : DIType(N) {}
unsigned getEncoding() const { return getUnsignedField(9); }
@ -287,10 +288,10 @@ namespace llvm {
/// a typedef, a pointer or reference, etc.
class DIDerivedType : public DIType {
protected:
explicit DIDerivedType(MDNode *N, bool, bool)
explicit DIDerivedType(const MDNode *N, bool, bool)
: DIType(N, true, true) {}
public:
explicit DIDerivedType(MDNode *N = 0)
explicit DIDerivedType(const MDNode *N = 0)
: DIType(N, true, true) {}
DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
@ -316,7 +317,7 @@ namespace llvm {
/// FIXME: Why is this a DIDerivedType??
class DICompositeType : public DIDerivedType {
public:
explicit DICompositeType(MDNode *N = 0)
explicit DICompositeType(const MDNode *N = 0)
: DIDerivedType(N, true, true) {
if (N && !isCompositeType())
DbgNode = 0;
@ -341,7 +342,7 @@ namespace llvm {
/// DIGlobal - This is a common class for global variables and subprograms.
class DIGlobal : public DIDescriptor {
protected:
explicit DIGlobal(MDNode *N) : DIDescriptor(N) {}
explicit DIGlobal(const MDNode *N) : DIDescriptor(N) {}
public:
virtual ~DIGlobal() {}
@ -376,7 +377,7 @@ namespace llvm {
/// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
class DISubprogram : public DIScope {
public:
explicit DISubprogram(MDNode *N = 0) : DIScope(N) {}
explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {}
DIScope getContext() const { return getFieldAs<DIScope>(2); }
StringRef getName() const { return getStringField(3); }
@ -452,7 +453,7 @@ namespace llvm {
/// DIGlobalVariable - This is a wrapper for a global variable.
class DIGlobalVariable : public DIGlobal {
public:
explicit DIGlobalVariable(MDNode *N = 0) : DIGlobal(N) {}
explicit DIGlobalVariable(const MDNode *N = 0) : DIGlobal(N) {}
GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
@ -470,7 +471,7 @@ namespace llvm {
/// global etc).
class DIVariable : public DIDescriptor {
public:
explicit DIVariable(MDNode *N = 0)
explicit DIVariable(const MDNode *N = 0)
: DIDescriptor(N) {}
DIScope getContext() const { return getFieldAs<DIScope>(1); }
@ -520,7 +521,7 @@ namespace llvm {
/// DILexicalBlock - This is a wrapper for a lexical block.
class DILexicalBlock : public DIScope {
public:
explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {}
explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {}
DIScope getContext() const { return getFieldAs<DIScope>(1); }
StringRef getDirectory() const { return getContext().getDirectory(); }
StringRef getFilename() const { return getContext().getFilename(); }
@ -531,7 +532,7 @@ namespace llvm {
/// DINameSpace - A wrapper for a C++ style name space.
class DINameSpace : public DIScope {
public:
explicit DINameSpace(MDNode *N = 0) : DIScope(N) {}
explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {}
DIScope getContext() const { return getFieldAs<DIScope>(1); }
StringRef getName() const { return getStringField(2); }
StringRef getDirectory() const { return getContext().getDirectory(); }
@ -550,7 +551,7 @@ namespace llvm {
/// is not associated with any DWARF tag.
class DILocation : public DIDescriptor {
public:
explicit DILocation(MDNode *N) : DIDescriptor(N) { }
explicit DILocation(const MDNode *N) : DIDescriptor(N) { }
unsigned getLineNumber() const { return getUnsignedField(0); }
unsigned getColumnNumber() const { return getUnsignedField(1); }
@ -749,7 +750,7 @@ namespace llvm {
std::string &Dir);
/// getDISubprogram - Find subprogram that is enclosing this scope.
DISubprogram getDISubprogram(MDNode *Scope);
DISubprogram getDISubprogram(const MDNode *Scope);
/// getDICompositeType - Find underlying composite type.
DICompositeType getDICompositeType(DIType T);

View File

@ -34,7 +34,7 @@ using namespace llvm::dwarf;
/// ValidDebugInfo - Return true if V represents valid debug info value.
/// FIXME : Add DIDescriptor.isValid()
bool DIDescriptor::ValidDebugInfo(MDNode *N, unsigned OptLevel) {
bool DIDescriptor::ValidDebugInfo(const MDNode *N, unsigned OptLevel) {
if (!N)
return false;
@ -96,7 +96,7 @@ DIDescriptor DIDescriptor::getDescriptorField(unsigned Elt) const {
return DIDescriptor();
if (Elt < DbgNode->getNumOperands())
return DIDescriptor(dyn_cast_or_null<MDNode>(DbgNode->getOperand(Elt)));
return DIDescriptor(dyn_cast_or_null<const MDNode>(DbgNode->getOperand(Elt)));
return DIDescriptor();
}
@ -246,7 +246,7 @@ bool DIDescriptor::isEnumerator() const {
// Simple Descriptor Constructors and other Methods
//===----------------------------------------------------------------------===//
DIType::DIType(MDNode *N) : DIScope(N) {
DIType::DIType(const MDNode *N) : DIScope(N) {
if (!N) return;
if (!isBasicType() && !isDerivedType() && !isCompositeType()) {
DbgNode = 0;
@ -272,8 +272,10 @@ void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) {
// this detail by allowing a value to be replaced with replaceAllUsesWith()
// itself.
if (DbgNode != D) {
MDNode *Node = DbgNode;
Node->replaceAllUsesWith(D);
MDNode *Node = const_cast<MDNode*>(DbgNode);
const MDNode *DN = D;
const Value *V = cast_or_null<Value>(DN);
Node->replaceAllUsesWith(const_cast<Value*>(V));
Node->destroy();
}
}
@ -1154,7 +1156,7 @@ DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo,
Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
Instruction *InsertBefore) {
assert(Storage && "no storage passed to dbg.declare");
assert(D && "empty DIVariable passed to dbg.declare");
assert(D.Verify() && "empty DIVariable passed to dbg.declare");
if (!DeclareFn)
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
@ -1167,7 +1169,7 @@ Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
BasicBlock *InsertAtEnd) {
assert(Storage && "no storage passed to dbg.declare");
assert(D && "empty DIVariable passed to dbg.declare");
assert(D.Verify() && "invalid DIVariable passed to dbg.declare");
if (!DeclareFn)
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
@ -1186,7 +1188,7 @@ Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
DIVariable D,
Instruction *InsertBefore) {
assert(V && "no value passed to dbg.value");
assert(D && "empty DIVariable passed to dbg.value");
assert(D.Verify() && "invalid DIVariable passed to dbg.value");
if (!ValueFn)
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
@ -1201,7 +1203,7 @@ Instruction *DIFactory::InsertDbgValueIntrinsic(Value *V, uint64_t Offset,
DIVariable D,
BasicBlock *InsertAtEnd) {
assert(V && "no value passed to dbg.value");
assert(D && "empty DIVariable passed to dbg.value");
assert(D.Verify() && "invalid DIVariable passed to dbg.value");
if (!ValueFn)
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
@ -1456,7 +1458,7 @@ bool llvm::getLocationInfo(const Value *V, std::string &DisplayName,
}
/// getDISubprogram - Find subprogram that is enclosing this scope.
DISubprogram llvm::getDISubprogram(MDNode *Scope) {
DISubprogram llvm::getDISubprogram(const MDNode *Scope) {
DIDescriptor D(Scope);
if (D.isSubprogram())
return DISubprogram(Scope);

View File

@ -82,12 +82,12 @@ class CompileUnit {
/// GVToDieMap - Tracks the mapping of unit level debug informaton
/// variables to debug information entries.
/// FIXME : Rename GVToDieMap -> NodeToDieMap
DenseMap<MDNode *, DIE *> GVToDieMap;
DenseMap<const MDNode *, DIE *> GVToDieMap;
/// GVToDIEEntryMap - Tracks the mapping of unit level debug informaton
/// descriptors to debug information entries using a DIEEntry proxy.
/// FIXME : Rename
DenseMap<MDNode *, DIEEntry *> GVToDIEEntryMap;
DenseMap<const MDNode *, DIEEntry *> GVToDIEEntryMap;
/// Globals - A map of globally visible named entities for this unit.
///
@ -123,24 +123,24 @@ public:
/// getDIE - Returns the debug information entry map slot for the
/// specified debug variable.
DIE *getDIE(MDNode *N) { return GVToDieMap.lookup(N); }
DIE *getDIE(const MDNode *N) { return GVToDieMap.lookup(N); }
/// insertDIE - Insert DIE into the map.
void insertDIE(MDNode *N, DIE *D) {
void insertDIE(const MDNode *N, DIE *D) {
GVToDieMap.insert(std::make_pair(N, D));
}
/// getDIEEntry - Returns the debug information entry for the speciefied
/// debug variable.
DIEEntry *getDIEEntry(MDNode *N) {
DenseMap<MDNode *, DIEEntry *>::iterator I = GVToDIEEntryMap.find(N);
DIEEntry *getDIEEntry(const MDNode *N) {
DenseMap<const MDNode *, DIEEntry *>::iterator I = GVToDIEEntryMap.find(N);
if (I == GVToDIEEntryMap.end())
return NULL;
return I->second;
}
/// insertDIEEntry - Insert debug information entry into the map.
void insertDIEEntry(MDNode *N, DIEEntry *E) {
void insertDIEEntry(const MDNode *N, DIEEntry *E) {
GVToDIEEntryMap.insert(std::make_pair(N, E));
}
@ -208,7 +208,7 @@ class DbgScope {
DbgScope *Parent; // Parent to this scope.
DIDescriptor Desc; // Debug info descriptor for scope.
// Location at which this scope is inlined.
AssertingVH<MDNode> InlinedAtLocation;
AssertingVH<const MDNode> InlinedAtLocation;
bool AbstractScope; // Abstract Scope
const MachineInstr *LastInsn; // Last instruction of this scope.
const MachineInstr *FirstInsn; // First instruction of this scope.
@ -221,7 +221,7 @@ class DbgScope {
// Private state for dump()
mutable unsigned IndentLevel;
public:
DbgScope(DbgScope *P, DIDescriptor D, MDNode *I = 0)
DbgScope(DbgScope *P, DIDescriptor D, const MDNode *I = 0)
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(false),
LastInsn(0), FirstInsn(0),
DFSIn(0), DFSOut(0), IndentLevel(0) {}
@ -231,8 +231,8 @@ public:
DbgScope *getParent() const { return Parent; }
void setParent(DbgScope *P) { Parent = P; }
DIDescriptor getDesc() const { return Desc; }
MDNode *getInlinedAt() const { return InlinedAtLocation; }
MDNode *getScopeNode() const { return Desc; }
const MDNode *getInlinedAt() const { return InlinedAtLocation; }
const MDNode *getScopeNode() const { return Desc; }
const SmallVector<DbgScope *, 4> &getScopes() { return Scopes; }
const SmallVector<DbgVariable *, 8> &getVariables() { return Variables; }
const SmallVector<DbgRange, 4> &getRanges() { return Ranges; }
@ -304,7 +304,7 @@ public:
void DbgScope::dump() const {
raw_ostream &err = dbgs();
err.indent(IndentLevel);
MDNode *N = Desc;
const MDNode *N = Desc;
N->dump();
if (AbstractScope)
err << "Abstract Scope\n";
@ -1344,7 +1344,7 @@ DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) {
return SPDie;
}
DbgScope *DwarfDebug::getOrCreateAbstractScope(MDNode *N) {
DbgScope *DwarfDebug::getOrCreateAbstractScope(const MDNode *N) {
assert(N && "Invalid Scope encoding!");
DbgScope *AScope = AbstractScopes.lookup(N);
@ -1373,7 +1373,7 @@ DbgScope *DwarfDebug::getOrCreateAbstractScope(MDNode *N) {
/// isSubprogramContext - Return true if Context is either a subprogram
/// or another context nested inside a subprogram.
static bool isSubprogramContext(MDNode *Context) {
static bool isSubprogramContext(const MDNode *Context) {
if (!Context)
return false;
DIDescriptor D(Context);
@ -1388,7 +1388,7 @@ static bool isSubprogramContext(MDNode *Context) {
/// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
/// If there are global variables in this scope then create and insert
/// DIEs for these variables.
DIE *DwarfDebug::updateSubprogramScopeDIE(MDNode *SPNode) {
DIE *DwarfDebug::updateSubprogramScopeDIE(const MDNode *SPNode) {
DIE *SPDie = ModuleCU->getDIE(SPNode);
assert(SPDie && "Unable to find subprogram DIE!");
DISubprogram SP(SPNode);
@ -1520,7 +1520,7 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) {
InlinedSubprogramDIEs.insert(OriginDIE);
// Track the start label for this inlined function.
DenseMap<MDNode *, SmallVector<InlineInfoLabels, 4> >::iterator
DenseMap<const MDNode *, SmallVector<InlineInfoLabels, 4> >::iterator
I = InlineInfo.find(InlinedSP);
if (I == InlineInfo.end()) {
@ -1760,7 +1760,7 @@ DIE *DwarfDebug::getOrCreateNameSpace(DINameSpace NS) {
return NDie;
}
void DwarfDebug::constructCompileUnit(MDNode *N) {
void DwarfDebug::constructCompileUnit(const MDNode *N) {
DICompileUnit DIUnit(N);
// Use first compile unit marked as isMain as the compile unit for this
// module.
@ -1803,7 +1803,7 @@ void DwarfDebug::constructCompileUnit(MDNode *N) {
ModuleCU = new CompileUnit(ID, Die);
}
void DwarfDebug::constructGlobalVariableDIE(MDNode *N) {
void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) {
DIGlobalVariable DI_GV(N);
// If debug information is malformed then ignore it.
@ -1861,7 +1861,7 @@ void DwarfDebug::constructGlobalVariableDIE(MDNode *N) {
return;
}
void DwarfDebug::constructSubprogramDIE(MDNode *N) {
void DwarfDebug::constructSubprogramDIE(const MDNode *N) {
DISubprogram SP(N);
// Check for pre-existence.
@ -1965,10 +1965,10 @@ void DwarfDebug::endModule() {
addUInt(ISP, dwarf::DW_AT_inline, 0, dwarf::DW_INL_inlined);
}
for (DenseMap<DIE *, MDNode *>::iterator CI = ContainingTypeMap.begin(),
for (DenseMap<DIE *, const MDNode *>::iterator CI = ContainingTypeMap.begin(),
CE = ContainingTypeMap.end(); CI != CE; ++CI) {
DIE *SPDie = CI->first;
MDNode *N = dyn_cast_or_null<MDNode>(CI->second);
const MDNode *N = dyn_cast_or_null<MDNode>(CI->second);
if (!N) continue;
DIE *NDie = ModuleCU->getDIE(N);
if (!NDie) continue;
@ -2086,13 +2086,13 @@ void DwarfDebug::collectVariableInfo() {
MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo();
for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(),
VE = VMap.end(); VI != VE; ++VI) {
MDNode *Var = VI->first;
const MDNode *Var = VI->first;
if (!Var) continue;
DIVariable DV(Var);
const std::pair<unsigned, DebugLoc> &VP = VI->second;
DbgScope *Scope = 0;
if (MDNode *IA = VP.second.getInlinedAt(Ctx))
if (const MDNode *IA = VP.second.getInlinedAt(Ctx))
Scope = ConcreteScopes.lookup(IA);
if (Scope == 0)
Scope = DbgScopeMap.lookup(VP.second.getScope(Ctx));
@ -2120,7 +2120,7 @@ void DwarfDebug::collectVariableInfo() {
continue;
DIVariable DV(
const_cast<MDNode *>(MInsn->getOperand(MInsn->getNumOperands() - 1)
const_cast<const MDNode *>(MInsn->getOperand(MInsn->getNumOperands() - 1)
.getMetadata()));
if (DV.getTag() == dwarf::DW_TAG_arg_variable) {
// FIXME Handle inlined subroutine arguments.
@ -2133,7 +2133,7 @@ void DwarfDebug::collectVariableInfo() {
DebugLoc DL = MInsn->getDebugLoc();
if (DL.isUnknown()) continue;
DbgScope *Scope = 0;
if (MDNode *IA = DL.getInlinedAt(Ctx))
if (const MDNode *IA = DL.getInlinedAt(Ctx))
Scope = ConcreteScopes.lookup(IA);
if (Scope == 0)
Scope = DbgScopeMap.lookup(DL.getScope(Ctx));
@ -2176,7 +2176,7 @@ void DwarfDebug::beginScope(const MachineInstr *MI) {
return;
}
MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext());
const MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext());
// FIXME: Should only verify each scope once!
if (!DIScope(Scope).Verify())
@ -2227,7 +2227,7 @@ void DwarfDebug::endScope(const MachineInstr *MI) {
}
/// getOrCreateDbgScope - Create DbgScope for the scope.
DbgScope *DwarfDebug::getOrCreateDbgScope(MDNode *Scope, MDNode *InlinedAt) {
DbgScope *DwarfDebug::getOrCreateDbgScope(const MDNode *Scope, const MDNode *InlinedAt) {
if (!InlinedAt) {
DbgScope *WScope = DbgScopeMap.lookup(Scope);
if (WScope)
@ -2272,13 +2272,13 @@ DbgScope *DwarfDebug::getOrCreateDbgScope(MDNode *Scope, MDNode *InlinedAt) {
/// machine instruction encodes valid location info.
static bool hasValidLocation(LLVMContext &Ctx,
const MachineInstr *MInsn,
MDNode *&Scope, MDNode *&InlinedAt) {
const MDNode *&Scope, const MDNode *&InlinedAt) {
if (MInsn->isDebugValue())
return false;
DebugLoc DL = MInsn->getDebugLoc();
if (DL.isUnknown()) return false;
MDNode *S = DL.getScope(Ctx);
const MDNode *S = DL.getScope(Ctx);
// There is no need to create another DIE for compile unit. For all
// other scopes, create one DbgScope now. This will be translated
@ -2330,8 +2330,8 @@ void printDbgScopeInfo(LLVMContext &Ctx, const MachineFunction *MF,
for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
II != IE; ++II) {
const MachineInstr *MInsn = II;
MDNode *Scope = NULL;
MDNode *InlinedAt = NULL;
const MDNode *Scope = NULL;
const MDNode *InlinedAt = NULL;
// Check if instruction has valid location information.
if (hasValidLocation(Ctx, MInsn, Scope, InlinedAt)) {
@ -2367,8 +2367,8 @@ bool DwarfDebug::extractScopeInformation() {
LLVMContext &Ctx = Asm->MF->getFunction()->getContext();
SmallVector<DbgRange, 4> MIRanges;
DenseMap<const MachineInstr *, DbgScope *> MI2ScopeMap;
MDNode *PrevScope = NULL;
MDNode *PrevInlinedAt = NULL;
const MDNode *PrevScope = NULL;
const MDNode *PrevInlinedAt = NULL;
const MachineInstr *RangeBeginMI = NULL;
const MachineInstr *PrevMI = NULL;
for (MachineFunction::const_iterator I = Asm->MF->begin(), E = Asm->MF->end();
@ -2376,8 +2376,8 @@ bool DwarfDebug::extractScopeInformation() {
for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
II != IE; ++II) {
const MachineInstr *MInsn = II;
MDNode *Scope = NULL;
MDNode *InlinedAt = NULL;
const MDNode *Scope = NULL;
const MDNode *InlinedAt = NULL;
// Check if instruction has valid location information.
if (!hasValidLocation(Ctx, MInsn, Scope, InlinedAt)) {
@ -2512,7 +2512,7 @@ void DwarfDebug::beginFunction(const MachineFunction *MF) {
DebugLoc FDL = FindFirstDebugLoc(MF);
if (FDL.isUnknown()) return;
MDNode *Scope = FDL.getScope(MF->getFunction()->getContext());
const MDNode *Scope = FDL.getScope(MF->getFunction()->getContext());
DISubprogram SP = getDISubprogram(Scope);
unsigned Line, Col;
@ -2583,7 +2583,7 @@ void DwarfDebug::endFunction(const MachineFunction *MF) {
/// recordSourceLine - Register a source line with debug info. Returns the
/// unique label that was emitted and which provides correspondence to
/// the source line list.
MCSymbol *DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, MDNode *S) {
MCSymbol *DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S) {
StringRef Dir;
StringRef Fn;
@ -3353,11 +3353,11 @@ void DwarfDebug::emitDebugInlineInfo() {
Asm->OutStreamer.AddComment("Address Size (in bytes)");
Asm->EmitInt8(Asm->getTargetData().getPointerSize());
for (SmallVector<MDNode *, 4>::iterator I = InlinedSPNodes.begin(),
for (SmallVector<const MDNode *, 4>::iterator I = InlinedSPNodes.begin(),
E = InlinedSPNodes.end(); I != E; ++I) {
MDNode *Node = *I;
DenseMap<MDNode *, SmallVector<InlineInfoLabels, 4> >::iterator II
const MDNode *Node = *I;
DenseMap<const MDNode *, SmallVector<InlineInfoLabels, 4> >::iterator II
= InlineInfo.find(Node);
SmallVector<InlineInfoLabels, 4> &Labels = II->second;
DISubprogram SP(Node);

View File

@ -146,15 +146,15 @@ class DwarfDebug {
/// DbgScopeMap - Tracks the scopes in the current function. Owns the
/// contained DbgScope*s.
///
DenseMap<MDNode *, DbgScope *> DbgScopeMap;
DenseMap<const MDNode *, DbgScope *> DbgScopeMap;
/// ConcreteScopes - Tracks the concrete scopees in the current function.
/// These scopes are also included in DbgScopeMap.
DenseMap<MDNode *, DbgScope *> ConcreteScopes;
DenseMap<const MDNode *, DbgScope *> ConcreteScopes;
/// AbstractScopes - Tracks the abstract scopes a module. These scopes are
/// not included DbgScopeMap. AbstractScopes owns its DbgScope*s.
DenseMap<MDNode *, DbgScope *> AbstractScopes;
DenseMap<const MDNode *, DbgScope *> AbstractScopes;
/// AbstractScopesList - Tracks abstract scopes constructed while processing
/// a function. This list is cleared during endFunction().
@ -162,7 +162,7 @@ class DwarfDebug {
/// AbstractVariables - Collection on abstract variables. Owned by the
/// DbgScopes in AbstractScopes.
DenseMap<MDNode *, DbgVariable *> AbstractVariables;
DenseMap<const MDNode *, DbgVariable *> AbstractVariables;
/// DbgValueStartMap - Tracks starting scope of variable DIEs.
/// If the scope of an object begins sometime after the low pc value for the
@ -177,7 +177,7 @@ class DwarfDebug {
/// ContainingTypeMap - This map is used to keep track of subprogram DIEs that
/// need DW_AT_containing_type attribute. This attribute points to a DIE that
/// corresponds to the MDNode mapped with the subprogram DIE.
DenseMap<DIE *, MDNode *> ContainingTypeMap;
DenseMap<DIE *, const MDNode *> ContainingTypeMap;
typedef SmallVector<DbgScope *, 2> ScopeVector;
SmallPtrSet<const MachineInstr *, 8> InsnsBeginScopeSet;
@ -185,9 +185,9 @@ class DwarfDebug {
/// InlineInfo - Keep track of inlined functions and their location. This
/// information is used to populate debug_inlined section.
typedef std::pair<MCSymbol*, DIE *> InlineInfoLabels;
DenseMap<MDNode*, SmallVector<InlineInfoLabels, 4> > InlineInfo;
SmallVector<MDNode *, 4> InlinedSPNodes;
typedef std::pair<MCSymbol *, DIE *> InlineInfoLabels;
DenseMap<const MDNode *, SmallVector<InlineInfoLabels, 4> > InlineInfo;
SmallVector<const MDNode *, 4> InlinedSPNodes;
/// LabelsBeforeInsn - Maps instruction with label emitted before
/// instruction.
@ -380,9 +380,9 @@ private:
DIE *createSubprogramDIE(const DISubprogram &SP, bool MakeDecl = false);
/// getOrCreateDbgScope - Create DbgScope for the scope.
DbgScope *getOrCreateDbgScope(MDNode *Scope, MDNode *InlinedAt);
DbgScope *getOrCreateDbgScope(const MDNode *Scope, const MDNode *InlinedAt);
DbgScope *getOrCreateAbstractScope(MDNode *N);
DbgScope *getOrCreateAbstractScope(const MDNode *N);
/// findAbstractVariable - Find abstract variable associated with Var.
DbgVariable *findAbstractVariable(DIVariable &Var, unsigned FrameIdx,
@ -394,7 +394,7 @@ private:
/// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
/// If there are global variables in this scope then create and insert
/// DIEs for these variables.
DIE *updateSubprogramScopeDIE(MDNode *SPNode);
DIE *updateSubprogramScopeDIE(const MDNode *SPNode);
/// constructLexicalScope - Construct new DW_TAG_lexical_block
/// for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
@ -506,11 +506,11 @@ private:
/// maps as well.
unsigned GetOrCreateSourceID(StringRef DirName, StringRef FileName);
void constructCompileUnit(MDNode *N);
void constructCompileUnit(const MDNode *N);
void constructGlobalVariableDIE(MDNode *N);
void constructGlobalVariableDIE(const MDNode *N);
void constructSubprogramDIE(MDNode *N);
void constructSubprogramDIE(const MDNode *N);
// FIXME: This should go away in favor of complex addresses.
/// Find the type the programmer originally declared the variable to be
@ -521,7 +521,7 @@ private:
/// recordSourceLine - Register a source line with debug info. Returns the
/// unique label that was emitted and which provides correspondence to
/// the source line list.
MCSymbol *recordSourceLine(unsigned Line, unsigned Col, MDNode *Scope);
MCSymbol *recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope);
/// getSourceLineCount - Return the number of source lines in the debug
/// info.

View File

@ -886,7 +886,7 @@ void PromoteMem2Reg::PromoteSingleBlockAlloca(AllocaInst *AI, AllocaInfo &Info,
void PromoteMem2Reg::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
StoreInst *SI) {
DIVariable DIVar(DDI->getVariable());
if (!DIVar)
if (!DIVar.Verify())
return;
if (!DIF)