mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
Print function info. Patch by Minjang Kim.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125567 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ab4c366274
commit
497acb91dc
@ -66,8 +66,12 @@ void PrintDbgInfo::printVariableDeclaration(const Value *V) {
|
|||||||
|
|
||||||
Out << "; ";
|
Out << "; ";
|
||||||
WriteAsOperand(Out, V, false, 0);
|
WriteAsOperand(Out, V, false, 0);
|
||||||
Out << " is variable " << DisplayName
|
if (isa<Function>(V))
|
||||||
<< " of type " << Type << " declared at ";
|
Out << " is function " << DisplayName
|
||||||
|
<< " of type " << Type << " declared at ";
|
||||||
|
else
|
||||||
|
Out << " is variable " << DisplayName
|
||||||
|
<< " of type " << Type << " declared at ";
|
||||||
|
|
||||||
if (PrintDirectory)
|
if (PrintDirectory)
|
||||||
Out << Directory << "/";
|
Out << Directory << "/";
|
||||||
|
@ -1592,6 +1592,23 @@ static Value *findDbgGlobalDeclare(GlobalVariable *V) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Find the debug info descriptor corresponding to this function.
|
||||||
|
static Value *findDbgSubprogramDeclare(Function *V) {
|
||||||
|
const Module *M = V->getParent();
|
||||||
|
NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.sp");
|
||||||
|
if (!NMD)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
|
||||||
|
DIDescriptor DIG(cast<MDNode>(NMD->getOperand(i)));
|
||||||
|
if (!DIG.isSubprogram())
|
||||||
|
continue;
|
||||||
|
if (DISubprogram(DIG).getFunction() == V)
|
||||||
|
return DIG;
|
||||||
|
}
|
||||||
|
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.
|
||||||
static const DbgDeclareInst *findDbgDeclare(const Value *V) {
|
static const DbgDeclareInst *findDbgDeclare(const Value *V) {
|
||||||
@ -1627,6 +1644,17 @@ bool llvm::getLocationInfo(const Value *V, std::string &DisplayName,
|
|||||||
if (!DIGV) return false;
|
if (!DIGV) return false;
|
||||||
DIGlobalVariable Var(cast<MDNode>(DIGV));
|
DIGlobalVariable Var(cast<MDNode>(DIGV));
|
||||||
|
|
||||||
|
StringRef D = Var.getDisplayName();
|
||||||
|
if (!D.empty())
|
||||||
|
DisplayName = D;
|
||||||
|
LineNo = Var.getLineNumber();
|
||||||
|
Unit = Var.getCompileUnit();
|
||||||
|
TypeD = Var.getType();
|
||||||
|
} else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){
|
||||||
|
Value *DIF = findDbgSubprogramDeclare(F);
|
||||||
|
if (!DIF) return false;
|
||||||
|
DISubprogram Var(cast<MDNode>(DIF));
|
||||||
|
|
||||||
StringRef D = Var.getDisplayName();
|
StringRef D = Var.getDisplayName();
|
||||||
if (!D.empty())
|
if (!D.empty())
|
||||||
DisplayName = D;
|
DisplayName = D;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user