mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 03:29:40 +00:00
major cleanups, much of this file was incorrectly indented.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92262 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
784b850e32
commit
099b779a02
@ -46,8 +46,7 @@ bool DIDescriptor::ValidDebugInfo(MDNode *N, unsigned OptLevel) {
|
|||||||
if (Version != LLVMDebugVersion && Version != LLVMDebugVersion6)
|
if (Version != LLVMDebugVersion && Version != LLVMDebugVersion6)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned Tag = DI.getTag();
|
switch (DI.getTag()) {
|
||||||
switch (Tag) {
|
|
||||||
case DW_TAG_variable:
|
case DW_TAG_variable:
|
||||||
assert(DIVariable(N).Verify() && "Invalid DebugInfo value");
|
assert(DIVariable(N).Verify() && "Invalid DebugInfo value");
|
||||||
break;
|
break;
|
||||||
@ -128,18 +127,14 @@ GlobalVariable *DIDescriptor::getGlobalVariableField(unsigned Elt) const {
|
|||||||
/// isBasicType - Return true if the specified tag is legal for
|
/// isBasicType - Return true if the specified tag is legal for
|
||||||
/// DIBasicType.
|
/// DIBasicType.
|
||||||
bool DIDescriptor::isBasicType() const {
|
bool DIDescriptor::isBasicType() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_base_type;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_base_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isDerivedType - Return true if the specified tag is legal for DIDerivedType.
|
/// isDerivedType - Return true if the specified tag is legal for DIDerivedType.
|
||||||
bool DIDescriptor::isDerivedType() const {
|
bool DIDescriptor::isDerivedType() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
switch (getTag()) {
|
||||||
|
|
||||||
switch (Tag) {
|
|
||||||
case dwarf::DW_TAG_typedef:
|
case dwarf::DW_TAG_typedef:
|
||||||
case dwarf::DW_TAG_pointer_type:
|
case dwarf::DW_TAG_pointer_type:
|
||||||
case dwarf::DW_TAG_reference_type:
|
case dwarf::DW_TAG_reference_type:
|
||||||
@ -158,10 +153,8 @@ bool DIDescriptor::isDerivedType() const {
|
|||||||
/// isCompositeType - Return true if the specified tag is legal for
|
/// isCompositeType - Return true if the specified tag is legal for
|
||||||
/// DICompositeType.
|
/// DICompositeType.
|
||||||
bool DIDescriptor::isCompositeType() const {
|
bool DIDescriptor::isCompositeType() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
switch (getTag()) {
|
||||||
|
|
||||||
switch (Tag) {
|
|
||||||
case dwarf::DW_TAG_array_type:
|
case dwarf::DW_TAG_array_type:
|
||||||
case dwarf::DW_TAG_structure_type:
|
case dwarf::DW_TAG_structure_type:
|
||||||
case dwarf::DW_TAG_union_type:
|
case dwarf::DW_TAG_union_type:
|
||||||
@ -177,10 +170,8 @@ bool DIDescriptor::isCompositeType() const {
|
|||||||
|
|
||||||
/// isVariable - Return true if the specified tag is legal for DIVariable.
|
/// isVariable - Return true if the specified tag is legal for DIVariable.
|
||||||
bool DIDescriptor::isVariable() const {
|
bool DIDescriptor::isVariable() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
switch (getTag()) {
|
||||||
|
|
||||||
switch (Tag) {
|
|
||||||
case dwarf::DW_TAG_auto_variable:
|
case dwarf::DW_TAG_auto_variable:
|
||||||
case dwarf::DW_TAG_arg_variable:
|
case dwarf::DW_TAG_arg_variable:
|
||||||
case dwarf::DW_TAG_return_variable:
|
case dwarf::DW_TAG_return_variable:
|
||||||
@ -198,19 +189,15 @@ bool DIDescriptor::isType() const {
|
|||||||
/// isSubprogram - Return true if the specified tag is legal for
|
/// isSubprogram - Return true if the specified tag is legal for
|
||||||
/// DISubprogram.
|
/// DISubprogram.
|
||||||
bool DIDescriptor::isSubprogram() const {
|
bool DIDescriptor::isSubprogram() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_subprogram;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_subprogram;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isGlobalVariable - Return true if the specified tag is legal for
|
/// isGlobalVariable - Return true if the specified tag is legal for
|
||||||
/// DIGlobalVariable.
|
/// DIGlobalVariable.
|
||||||
bool DIDescriptor::isGlobalVariable() const {
|
bool DIDescriptor::isGlobalVariable() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_variable;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_variable;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isGlobal - Return true if the specified tag is legal for DIGlobal.
|
/// isGlobal - Return true if the specified tag is legal for DIGlobal.
|
||||||
@ -221,59 +208,47 @@ bool DIDescriptor::isGlobal() const {
|
|||||||
/// isScope - Return true if the specified tag is one of the scope
|
/// isScope - Return true if the specified tag is one of the scope
|
||||||
/// related tag.
|
/// related tag.
|
||||||
bool DIDescriptor::isScope() const {
|
bool DIDescriptor::isScope() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
switch (getTag()) {
|
||||||
|
case dwarf::DW_TAG_compile_unit:
|
||||||
switch (Tag) {
|
case dwarf::DW_TAG_lexical_block:
|
||||||
case dwarf::DW_TAG_compile_unit:
|
case dwarf::DW_TAG_subprogram:
|
||||||
case dwarf::DW_TAG_lexical_block:
|
case dwarf::DW_TAG_namespace:
|
||||||
case dwarf::DW_TAG_subprogram:
|
return true;
|
||||||
case dwarf::DW_TAG_namespace:
|
default:
|
||||||
return true;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
|
/// isCompileUnit - Return true if the specified tag is DW_TAG_compile_unit.
|
||||||
bool DIDescriptor::isCompileUnit() const {
|
bool DIDescriptor::isCompileUnit() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_compile_unit;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_compile_unit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isNameSpace - Return true if the specified tag is DW_TAG_namespace.
|
/// isNameSpace - Return true if the specified tag is DW_TAG_namespace.
|
||||||
bool DIDescriptor::isNameSpace() const {
|
bool DIDescriptor::isNameSpace() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_namespace;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_namespace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block.
|
/// isLexicalBlock - Return true if the specified tag is DW_TAG_lexical_block.
|
||||||
bool DIDescriptor::isLexicalBlock() const {
|
bool DIDescriptor::isLexicalBlock() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_lexical_block;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_lexical_block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isSubrange - Return true if the specified tag is DW_TAG_subrange_type.
|
/// isSubrange - Return true if the specified tag is DW_TAG_subrange_type.
|
||||||
bool DIDescriptor::isSubrange() const {
|
bool DIDescriptor::isSubrange() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_subrange_type;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_subrange_type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isEnumerator - Return true if the specified tag is DW_TAG_enumerator.
|
/// isEnumerator - Return true if the specified tag is DW_TAG_enumerator.
|
||||||
bool DIDescriptor::isEnumerator() const {
|
bool DIDescriptor::isEnumerator() const {
|
||||||
assert (!isNull() && "Invalid descriptor!");
|
assert(!isNull() && "Invalid descriptor!");
|
||||||
unsigned Tag = getTag();
|
return getTag() == dwarf::DW_TAG_enumerator;
|
||||||
|
|
||||||
return Tag == dwarf::DW_TAG_enumerator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -288,7 +263,7 @@ DIType::DIType(MDNode *N) : DIDescriptor(N) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned DIArray::getNumElements() const {
|
unsigned DIArray::getNumElements() const {
|
||||||
assert (DbgNode && "Invalid DIArray");
|
assert(DbgNode && "Invalid DIArray");
|
||||||
return DbgNode->getNumElements();
|
return DbgNode->getNumElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +274,7 @@ void DIDerivedType::replaceAllUsesWith(DIDescriptor &D) {
|
|||||||
if (isNull())
|
if (isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert (!D.isNull() && "Can not replace with null");
|
assert(!D.isNull() && "Can not replace with null");
|
||||||
|
|
||||||
// Since we use a TrackingVH for the node, its easy for clients to manufacture
|
// Since we use a TrackingVH for the node, its easy for clients to manufacture
|
||||||
// legitimate situations where they want to replaceAllUsesWith() on something
|
// legitimate situations where they want to replaceAllUsesWith() on something
|
||||||
@ -432,7 +407,7 @@ uint64_t DIDerivedType::getOriginalTypeSize() const {
|
|||||||
/// describes - Return true if this subprogram provides debugging
|
/// describes - Return true if this subprogram provides debugging
|
||||||
/// information for the function F.
|
/// information for the function F.
|
||||||
bool DISubprogram::describes(const Function *F) {
|
bool DISubprogram::describes(const Function *F) {
|
||||||
assert (F && "Invalid function");
|
assert(F && "Invalid function");
|
||||||
StringRef Name = getLinkageName();
|
StringRef Name = getLinkageName();
|
||||||
if (Name.empty())
|
if (Name.empty())
|
||||||
Name = getName();
|
Name = getName();
|
||||||
@ -444,28 +419,26 @@ bool DISubprogram::describes(const Function *F) {
|
|||||||
StringRef DIScope::getFilename() const {
|
StringRef DIScope::getFilename() const {
|
||||||
if (isLexicalBlock())
|
if (isLexicalBlock())
|
||||||
return DILexicalBlock(DbgNode).getFilename();
|
return DILexicalBlock(DbgNode).getFilename();
|
||||||
else if (isSubprogram())
|
if (isSubprogram())
|
||||||
return DISubprogram(DbgNode).getFilename();
|
return DISubprogram(DbgNode).getFilename();
|
||||||
else if (isCompileUnit())
|
if (isCompileUnit())
|
||||||
return DICompileUnit(DbgNode).getFilename();
|
return DICompileUnit(DbgNode).getFilename();
|
||||||
else if (isNameSpace())
|
if (isNameSpace())
|
||||||
return DINameSpace(DbgNode).getFilename();
|
return DINameSpace(DbgNode).getFilename();
|
||||||
else
|
assert(0 && "Invalid DIScope!");
|
||||||
assert (0 && "Invalid DIScope!");
|
|
||||||
return StringRef();
|
return StringRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef DIScope::getDirectory() const {
|
StringRef DIScope::getDirectory() const {
|
||||||
if (isLexicalBlock())
|
if (isLexicalBlock())
|
||||||
return DILexicalBlock(DbgNode).getDirectory();
|
return DILexicalBlock(DbgNode).getDirectory();
|
||||||
else if (isSubprogram())
|
if (isSubprogram())
|
||||||
return DISubprogram(DbgNode).getDirectory();
|
return DISubprogram(DbgNode).getDirectory();
|
||||||
else if (isCompileUnit())
|
if (isCompileUnit())
|
||||||
return DICompileUnit(DbgNode).getDirectory();
|
return DICompileUnit(DbgNode).getDirectory();
|
||||||
else if (isNameSpace())
|
if (isNameSpace())
|
||||||
return DINameSpace(DbgNode).getDirectory();
|
return DINameSpace(DbgNode).getDirectory();
|
||||||
else
|
assert(0 && "Invalid DIScope!");
|
||||||
assert (0 && "Invalid DIScope!");
|
|
||||||
return StringRef();
|
return StringRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1264,270 +1237,267 @@ bool DebugInfoFinder::addSubprogram(DISubprogram SP) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace llvm {
|
/// findStopPoint - Find the stoppoint coressponding to this instruction, that
|
||||||
/// findStopPoint - Find the stoppoint coressponding to this instruction, that
|
/// is the stoppoint that dominates this instruction.
|
||||||
/// is the stoppoint that dominates this instruction.
|
const DbgStopPointInst *llvm::findStopPoint(const Instruction *Inst) {
|
||||||
const DbgStopPointInst *findStopPoint(const Instruction *Inst) {
|
if (const DbgStopPointInst *DSI = dyn_cast<DbgStopPointInst>(Inst))
|
||||||
if (const DbgStopPointInst *DSI = dyn_cast<DbgStopPointInst>(Inst))
|
return DSI;
|
||||||
return DSI;
|
|
||||||
|
|
||||||
const BasicBlock *BB = Inst->getParent();
|
const BasicBlock *BB = Inst->getParent();
|
||||||
BasicBlock::const_iterator I = Inst, B;
|
BasicBlock::const_iterator I = Inst, B;
|
||||||
while (BB) {
|
while (BB) {
|
||||||
B = BB->begin();
|
B = BB->begin();
|
||||||
|
|
||||||
// A BB consisting only of a terminator can't have a stoppoint.
|
// A BB consisting only of a terminator can't have a stoppoint.
|
||||||
while (I != B) {
|
while (I != B) {
|
||||||
--I;
|
--I;
|
||||||
if (const DbgStopPointInst *DSI = dyn_cast<DbgStopPointInst>(I))
|
|
||||||
return DSI;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This BB didn't have a stoppoint: if there is only one predecessor, look
|
|
||||||
// for a stoppoint there. We could use getIDom(), but that would require
|
|
||||||
// dominator info.
|
|
||||||
BB = I->getParent()->getUniquePredecessor();
|
|
||||||
if (BB)
|
|
||||||
I = BB->getTerminator();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// findBBStopPoint - Find the stoppoint corresponding to first real
|
|
||||||
/// (non-debug intrinsic) instruction in this Basic Block, and return the
|
|
||||||
/// stoppoint for it.
|
|
||||||
const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB) {
|
|
||||||
for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
|
||||||
if (const DbgStopPointInst *DSI = dyn_cast<DbgStopPointInst>(I))
|
if (const DbgStopPointInst *DSI = dyn_cast<DbgStopPointInst>(I))
|
||||||
return DSI;
|
return DSI;
|
||||||
|
}
|
||||||
|
|
||||||
// Fallback to looking for stoppoint of unique predecessor. Useful if this
|
// This BB didn't have a stoppoint: if there is only one predecessor, look
|
||||||
// BB contains no stoppoints, but unique predecessor does.
|
// for a stoppoint there. We could use getIDom(), but that would require
|
||||||
BB = BB->getUniquePredecessor();
|
// dominator info.
|
||||||
|
BB = I->getParent()->getUniquePredecessor();
|
||||||
if (BB)
|
if (BB)
|
||||||
return findStopPoint(BB->getTerminator());
|
I = BB->getTerminator();
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *findDbgGlobalDeclare(GlobalVariable *V) {
|
return 0;
|
||||||
const Module *M = V->getParent();
|
}
|
||||||
NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv");
|
|
||||||
if (!NMD)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) {
|
/// findBBStopPoint - Find the stoppoint corresponding to first real
|
||||||
DIGlobalVariable DIG(cast_or_null<MDNode>(NMD->getElement(i)));
|
/// (non-debug intrinsic) instruction in this Basic Block, and return the
|
||||||
if (DIG.isNull())
|
/// stoppoint for it.
|
||||||
continue;
|
const DbgStopPointInst *llvm::findBBStopPoint(const BasicBlock *BB) {
|
||||||
if (DIG.getGlobal() == V)
|
for(BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
||||||
return DIG.getNode();
|
if (const DbgStopPointInst *DSI = dyn_cast<DbgStopPointInst>(I))
|
||||||
}
|
return DSI;
|
||||||
|
|
||||||
|
// Fallback to looking for stoppoint of unique predecessor. Useful if this
|
||||||
|
// BB contains no stoppoints, but unique predecessor does.
|
||||||
|
BB = BB->getUniquePredecessor();
|
||||||
|
if (BB)
|
||||||
|
return findStopPoint(BB->getTerminator());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Value *llvm::findDbgGlobalDeclare(GlobalVariable *V) {
|
||||||
|
const Module *M = V->getParent();
|
||||||
|
NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv");
|
||||||
|
if (!NMD)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = NMD->getNumElements(); i != e; ++i) {
|
||||||
|
DIGlobalVariable DIG(cast_or_null<MDNode>(NMD->getElement(i)));
|
||||||
|
if (DIG.isNull())
|
||||||
|
continue;
|
||||||
|
if (DIG.getGlobal() == V)
|
||||||
|
return DIG.getNode();
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// Finds the llvm.dbg.declare intrinsic corresponding to this value if any.
|
/// Finds the llvm.dbg.declare intrinsic corresponding to this value if any.
|
||||||
/// It looks through pointer casts too.
|
/// It looks through pointer casts too.
|
||||||
const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts) {
|
const DbgDeclareInst *llvm::findDbgDeclare(const Value *V, bool stripCasts) {
|
||||||
if (stripCasts) {
|
if (stripCasts) {
|
||||||
V = V->stripPointerCasts();
|
V = V->stripPointerCasts();
|
||||||
|
|
||||||
// Look for the bitcast.
|
// Look for the bitcast.
|
||||||
for (Value::use_const_iterator I = V->use_begin(), E =V->use_end();
|
|
||||||
I != E; ++I)
|
|
||||||
if (isa<BitCastInst>(I)) {
|
|
||||||
const DbgDeclareInst *DDI = findDbgDeclare(*I, false);
|
|
||||||
if (DDI) return DDI;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find llvm.dbg.declare among uses of the instruction.
|
|
||||||
for (Value::use_const_iterator I = V->use_begin(), E =V->use_end();
|
for (Value::use_const_iterator I = V->use_begin(), E =V->use_end();
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I))
|
if (isa<BitCastInst>(I)) {
|
||||||
return DDI;
|
const DbgDeclareInst *DDI = findDbgDeclare(*I, false);
|
||||||
|
if (DDI) return DDI;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool getLocationInfo(const Value *V, std::string &DisplayName,
|
// Find llvm.dbg.declare among uses of the instruction.
|
||||||
std::string &Type, unsigned &LineNo, std::string &File,
|
for (Value::use_const_iterator I = V->use_begin(), E =V->use_end();
|
||||||
std::string &Dir) {
|
I != E; ++I)
|
||||||
DICompileUnit Unit;
|
if (const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I))
|
||||||
DIType TypeD;
|
return DDI;
|
||||||
|
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
|
return 0;
|
||||||
Value *DIGV = findDbgGlobalDeclare(GV);
|
}
|
||||||
if (!DIGV) return false;
|
|
||||||
DIGlobalVariable Var(cast<MDNode>(DIGV));
|
bool llvm::getLocationInfo(const Value *V, std::string &DisplayName,
|
||||||
|
std::string &Type, unsigned &LineNo,
|
||||||
StringRef D = Var.getDisplayName();
|
std::string &File, std::string &Dir) {
|
||||||
if (!D.empty())
|
DICompileUnit Unit;
|
||||||
DisplayName = D;
|
DIType TypeD;
|
||||||
LineNo = Var.getLineNumber();
|
|
||||||
Unit = Var.getCompileUnit();
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
|
||||||
TypeD = Var.getType();
|
Value *DIGV = findDbgGlobalDeclare(GV);
|
||||||
} else {
|
if (!DIGV) return false;
|
||||||
const DbgDeclareInst *DDI = findDbgDeclare(V);
|
DIGlobalVariable Var(cast<MDNode>(DIGV));
|
||||||
if (!DDI) return false;
|
|
||||||
DIVariable Var(cast<MDNode>(DDI->getVariable()));
|
StringRef D = Var.getDisplayName();
|
||||||
|
if (!D.empty())
|
||||||
StringRef D = Var.getName();
|
DisplayName = D;
|
||||||
if (!D.empty())
|
LineNo = Var.getLineNumber();
|
||||||
DisplayName = D;
|
Unit = Var.getCompileUnit();
|
||||||
LineNo = Var.getLineNumber();
|
TypeD = Var.getType();
|
||||||
Unit = Var.getCompileUnit();
|
} else {
|
||||||
TypeD = Var.getType();
|
const DbgDeclareInst *DDI = findDbgDeclare(V);
|
||||||
}
|
if (!DDI) return false;
|
||||||
|
DIVariable Var(cast<MDNode>(DDI->getVariable()));
|
||||||
StringRef T = TypeD.getName();
|
|
||||||
if (!T.empty())
|
StringRef D = Var.getName();
|
||||||
Type = T;
|
if (!D.empty())
|
||||||
StringRef F = Unit.getFilename();
|
DisplayName = D;
|
||||||
if (!F.empty())
|
LineNo = Var.getLineNumber();
|
||||||
File = F;
|
Unit = Var.getCompileUnit();
|
||||||
StringRef D = Unit.getDirectory();
|
TypeD = Var.getType();
|
||||||
if (!D.empty())
|
}
|
||||||
Dir = D;
|
|
||||||
return true;
|
StringRef T = TypeD.getName();
|
||||||
}
|
if (!T.empty())
|
||||||
|
Type = T;
|
||||||
/// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug
|
StringRef F = Unit.getFilename();
|
||||||
/// info intrinsic.
|
if (!F.empty())
|
||||||
bool isValidDebugInfoIntrinsic(DbgStopPointInst &SPI, unsigned OptLev) {
|
File = F;
|
||||||
return DIDescriptor::ValidDebugInfo(SPI.getContext(), OptLev);
|
StringRef D = Unit.getDirectory();
|
||||||
}
|
if (!D.empty())
|
||||||
|
Dir = D;
|
||||||
/// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug
|
return true;
|
||||||
/// info intrinsic.
|
}
|
||||||
bool isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI, unsigned OptLev) {
|
|
||||||
return DIDescriptor::ValidDebugInfo(FSI.getSubprogram(), OptLev);
|
/// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug
|
||||||
}
|
/// info intrinsic.
|
||||||
|
bool llvm::isValidDebugInfoIntrinsic(DbgStopPointInst &SPI, unsigned OptLev) {
|
||||||
/// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug
|
return DIDescriptor::ValidDebugInfo(SPI.getContext(), OptLev);
|
||||||
/// info intrinsic.
|
}
|
||||||
bool isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI, unsigned OptLev) {
|
|
||||||
return DIDescriptor::ValidDebugInfo(RSI.getContext(), OptLev);
|
/// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug
|
||||||
}
|
/// info intrinsic.
|
||||||
|
bool llvm::isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI, unsigned OptLev) {
|
||||||
/// isValidDebugInfoIntrinsic - Return true if REI is a valid debug
|
return DIDescriptor::ValidDebugInfo(FSI.getSubprogram(), OptLev);
|
||||||
/// info intrinsic.
|
}
|
||||||
bool isValidDebugInfoIntrinsic(DbgRegionEndInst &REI, unsigned OptLev) {
|
|
||||||
return DIDescriptor::ValidDebugInfo(REI.getContext(), OptLev);
|
/// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug
|
||||||
}
|
/// info intrinsic.
|
||||||
|
bool llvm::isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI, unsigned OptLev) {
|
||||||
|
return DIDescriptor::ValidDebugInfo(RSI.getContext(), OptLev);
|
||||||
/// isValidDebugInfoIntrinsic - Return true if DI is a valid debug
|
}
|
||||||
/// info intrinsic.
|
|
||||||
bool isValidDebugInfoIntrinsic(DbgDeclareInst &DI, unsigned OptLev) {
|
/// isValidDebugInfoIntrinsic - Return true if REI is a valid debug
|
||||||
return DIDescriptor::ValidDebugInfo(DI.getVariable(), OptLev);
|
/// info intrinsic.
|
||||||
}
|
bool llvm::isValidDebugInfoIntrinsic(DbgRegionEndInst &REI, unsigned OptLev) {
|
||||||
|
return DIDescriptor::ValidDebugInfo(REI.getContext(), OptLev);
|
||||||
/// ExtractDebugLocation - Extract debug location information
|
}
|
||||||
/// from llvm.dbg.stoppoint intrinsic.
|
|
||||||
DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI,
|
/// isValidDebugInfoIntrinsic - Return true if DI is a valid debug
|
||||||
DebugLocTracker &DebugLocInfo) {
|
/// info intrinsic.
|
||||||
DebugLoc DL;
|
bool llvm::isValidDebugInfoIntrinsic(DbgDeclareInst &DI, unsigned OptLev) {
|
||||||
Value *Context = SPI.getContext();
|
return DIDescriptor::ValidDebugInfo(DI.getVariable(), OptLev);
|
||||||
|
}
|
||||||
// If this location is already tracked then use it.
|
|
||||||
DebugLocTuple Tuple(cast<MDNode>(Context), NULL, SPI.getLine(),
|
/// ExtractDebugLocation - Extract debug location information
|
||||||
SPI.getColumn());
|
/// from llvm.dbg.stoppoint intrinsic.
|
||||||
DenseMap<DebugLocTuple, unsigned>::iterator II
|
DebugLoc llvm::ExtractDebugLocation(DbgStopPointInst &SPI,
|
||||||
= DebugLocInfo.DebugIdMap.find(Tuple);
|
DebugLocTracker &DebugLocInfo) {
|
||||||
if (II != DebugLocInfo.DebugIdMap.end())
|
DebugLoc DL;
|
||||||
return DebugLoc::get(II->second);
|
Value *Context = SPI.getContext();
|
||||||
|
|
||||||
// Add a new location entry.
|
// If this location is already tracked then use it.
|
||||||
unsigned Id = DebugLocInfo.DebugLocations.size();
|
DebugLocTuple Tuple(cast<MDNode>(Context), NULL, SPI.getLine(),
|
||||||
DebugLocInfo.DebugLocations.push_back(Tuple);
|
SPI.getColumn());
|
||||||
DebugLocInfo.DebugIdMap[Tuple] = Id;
|
DenseMap<DebugLocTuple, unsigned>::iterator II
|
||||||
|
= DebugLocInfo.DebugIdMap.find(Tuple);
|
||||||
return DebugLoc::get(Id);
|
if (II != DebugLocInfo.DebugIdMap.end())
|
||||||
}
|
return DebugLoc::get(II->second);
|
||||||
|
|
||||||
/// ExtractDebugLocation - Extract debug location information
|
// Add a new location entry.
|
||||||
/// from DILocation.
|
unsigned Id = DebugLocInfo.DebugLocations.size();
|
||||||
DebugLoc ExtractDebugLocation(DILocation &Loc,
|
DebugLocInfo.DebugLocations.push_back(Tuple);
|
||||||
DebugLocTracker &DebugLocInfo) {
|
DebugLocInfo.DebugIdMap[Tuple] = Id;
|
||||||
DebugLoc DL;
|
|
||||||
MDNode *Context = Loc.getScope().getNode();
|
return DebugLoc::get(Id);
|
||||||
MDNode *InlinedLoc = NULL;
|
}
|
||||||
if (!Loc.getOrigLocation().isNull())
|
|
||||||
InlinedLoc = Loc.getOrigLocation().getNode();
|
/// ExtractDebugLocation - Extract debug location information
|
||||||
// If this location is already tracked then use it.
|
/// from DILocation.
|
||||||
DebugLocTuple Tuple(Context, InlinedLoc, Loc.getLineNumber(),
|
DebugLoc llvm::ExtractDebugLocation(DILocation &Loc,
|
||||||
Loc.getColumnNumber());
|
DebugLocTracker &DebugLocInfo) {
|
||||||
DenseMap<DebugLocTuple, unsigned>::iterator II
|
DebugLoc DL;
|
||||||
= DebugLocInfo.DebugIdMap.find(Tuple);
|
MDNode *Context = Loc.getScope().getNode();
|
||||||
if (II != DebugLocInfo.DebugIdMap.end())
|
MDNode *InlinedLoc = NULL;
|
||||||
return DebugLoc::get(II->second);
|
if (!Loc.getOrigLocation().isNull())
|
||||||
|
InlinedLoc = Loc.getOrigLocation().getNode();
|
||||||
// Add a new location entry.
|
// If this location is already tracked then use it.
|
||||||
unsigned Id = DebugLocInfo.DebugLocations.size();
|
DebugLocTuple Tuple(Context, InlinedLoc, Loc.getLineNumber(),
|
||||||
DebugLocInfo.DebugLocations.push_back(Tuple);
|
Loc.getColumnNumber());
|
||||||
DebugLocInfo.DebugIdMap[Tuple] = Id;
|
DenseMap<DebugLocTuple, unsigned>::iterator II
|
||||||
|
= DebugLocInfo.DebugIdMap.find(Tuple);
|
||||||
return DebugLoc::get(Id);
|
if (II != DebugLocInfo.DebugIdMap.end())
|
||||||
}
|
return DebugLoc::get(II->second);
|
||||||
|
|
||||||
/// ExtractDebugLocation - Extract debug location information
|
// Add a new location entry.
|
||||||
/// from llvm.dbg.func_start intrinsic.
|
unsigned Id = DebugLocInfo.DebugLocations.size();
|
||||||
DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI,
|
DebugLocInfo.DebugLocations.push_back(Tuple);
|
||||||
DebugLocTracker &DebugLocInfo) {
|
DebugLocInfo.DebugIdMap[Tuple] = Id;
|
||||||
DebugLoc DL;
|
|
||||||
Value *SP = FSI.getSubprogram();
|
return DebugLoc::get(Id);
|
||||||
|
}
|
||||||
DISubprogram Subprogram(cast<MDNode>(SP));
|
|
||||||
unsigned Line = Subprogram.getLineNumber();
|
/// ExtractDebugLocation - Extract debug location information
|
||||||
DICompileUnit CU(Subprogram.getCompileUnit());
|
/// from llvm.dbg.func_start intrinsic.
|
||||||
|
DebugLoc llvm::ExtractDebugLocation(DbgFuncStartInst &FSI,
|
||||||
// If this location is already tracked then use it.
|
DebugLocTracker &DebugLocInfo) {
|
||||||
DebugLocTuple Tuple(CU.getNode(), NULL, Line, /* Column */ 0);
|
DebugLoc DL;
|
||||||
DenseMap<DebugLocTuple, unsigned>::iterator II
|
Value *SP = FSI.getSubprogram();
|
||||||
= DebugLocInfo.DebugIdMap.find(Tuple);
|
|
||||||
if (II != DebugLocInfo.DebugIdMap.end())
|
DISubprogram Subprogram(cast<MDNode>(SP));
|
||||||
return DebugLoc::get(II->second);
|
unsigned Line = Subprogram.getLineNumber();
|
||||||
|
DICompileUnit CU(Subprogram.getCompileUnit());
|
||||||
// Add a new location entry.
|
|
||||||
unsigned Id = DebugLocInfo.DebugLocations.size();
|
// If this location is already tracked then use it.
|
||||||
DebugLocInfo.DebugLocations.push_back(Tuple);
|
DebugLocTuple Tuple(CU.getNode(), NULL, Line, /* Column */ 0);
|
||||||
DebugLocInfo.DebugIdMap[Tuple] = Id;
|
DenseMap<DebugLocTuple, unsigned>::iterator II
|
||||||
|
= DebugLocInfo.DebugIdMap.find(Tuple);
|
||||||
return DebugLoc::get(Id);
|
if (II != DebugLocInfo.DebugIdMap.end())
|
||||||
}
|
return DebugLoc::get(II->second);
|
||||||
|
|
||||||
/// getDISubprogram - Find subprogram that is enclosing this scope.
|
// Add a new location entry.
|
||||||
DISubprogram getDISubprogram(MDNode *Scope) {
|
unsigned Id = DebugLocInfo.DebugLocations.size();
|
||||||
DIDescriptor D(Scope);
|
DebugLocInfo.DebugLocations.push_back(Tuple);
|
||||||
if (D.isNull())
|
DebugLocInfo.DebugIdMap[Tuple] = Id;
|
||||||
return DISubprogram();
|
|
||||||
|
return DebugLoc::get(Id);
|
||||||
if (D.isCompileUnit())
|
}
|
||||||
return DISubprogram();
|
|
||||||
|
/// getDISubprogram - Find subprogram that is enclosing this scope.
|
||||||
if (D.isSubprogram())
|
DISubprogram llvm::getDISubprogram(MDNode *Scope) {
|
||||||
return DISubprogram(Scope);
|
DIDescriptor D(Scope);
|
||||||
|
if (D.isNull())
|
||||||
if (D.isLexicalBlock())
|
return DISubprogram();
|
||||||
return getDISubprogram(DILexicalBlock(Scope).getContext().getNode());
|
|
||||||
|
if (D.isCompileUnit())
|
||||||
return DISubprogram();
|
return DISubprogram();
|
||||||
}
|
|
||||||
|
if (D.isSubprogram())
|
||||||
/// getDICompositeType - Find underlying composite type.
|
return DISubprogram(Scope);
|
||||||
DICompositeType getDICompositeType(DIType T) {
|
|
||||||
if (T.isNull())
|
if (D.isLexicalBlock())
|
||||||
return DICompositeType();
|
return getDISubprogram(DILexicalBlock(Scope).getContext().getNode());
|
||||||
|
|
||||||
if (T.isCompositeType())
|
return DISubprogram();
|
||||||
return DICompositeType(T.getNode());
|
}
|
||||||
|
|
||||||
if (T.isDerivedType())
|
/// getDICompositeType - Find underlying composite type.
|
||||||
return getDICompositeType(DIDerivedType(T.getNode()).getTypeDerivedFrom());
|
DICompositeType llvm::getDICompositeType(DIType T) {
|
||||||
|
if (T.isNull())
|
||||||
return DICompositeType();
|
return DICompositeType();
|
||||||
}
|
|
||||||
|
if (T.isCompositeType())
|
||||||
|
return DICompositeType(T.getNode());
|
||||||
|
|
||||||
|
if (T.isDerivedType())
|
||||||
|
return getDICompositeType(DIDerivedType(T.getNode()).getTypeDerivedFrom());
|
||||||
|
|
||||||
|
return DICompositeType();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user