summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-07-20 22:18:50 +0000
committerDevang Patel <dpatel@apple.com>2011-07-20 22:18:50 +0000
commit8fb9fd6769b530eb05ab9e1db534948ed752a6e3 (patch)
tree274cea73ee1d766ea9bffc76b1a53c23518a74aa
parent911e12f50535689052dbe1f8cea5bd2f21a7ca3d (diff)
downloadbcm5719-llvm-8fb9fd6769b530eb05ab9e1db534948ed752a6e3.tar.gz
bcm5719-llvm-8fb9fd6769b530eb05ab9e1db534948ed752a6e3.zip
There are two ways to map a variable to its lexical scope. Lexical scope information is embedded in MDNode describing the variable. It is also available as a part of DebugLoc attached with DBG_VALUE instruction. DebugLoc attached with an instruction is less reliable in optimized code so use information embedded in the MDNode.
llvm-svn: 135629
-rw-r--r--llvm/include/llvm/Analysis/DebugInfo.h2
-rw-r--r--llvm/lib/Analysis/DebugInfo.cpp6
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp12
3 files changed, 18 insertions, 2 deletions
diff --git a/llvm/include/llvm/Analysis/DebugInfo.h b/llvm/include/llvm/Analysis/DebugInfo.h
index 152d11ef93a..929dd1d13a7 100644
--- a/llvm/include/llvm/Analysis/DebugInfo.h
+++ b/llvm/include/llvm/Analysis/DebugInfo.h
@@ -614,6 +614,8 @@ namespace llvm {
return (getUnsignedField(6) & FlagArtificial) != 0;
}
+ /// getInlinedAt - If this variable is inlined then return inline location.
+ MDNode *getInlinedAt();
/// Verify - Verify that a variable descriptor is well formed.
bool Verify() const;
diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp
index 4dcf04ef216..dd85a4fcc80 100644
--- a/llvm/lib/Analysis/DebugInfo.cpp
+++ b/llvm/lib/Analysis/DebugInfo.cpp
@@ -116,6 +116,12 @@ unsigned DIVariable::getNumAddrElements() const {
return DbgNode->getNumOperands()-8;
}
+/// getInlinedAt - If this variable is inlined then return inline location.
+MDNode *DIVariable::getInlinedAt() {
+ if (getVersion() <= llvm::LLVMDebugVersion9)
+ return NULL;
+ return dyn_cast_or_null<MDNode>(DbgNode->getOperand(7));
+}
//===----------------------------------------------------------------------===//
// Predicates
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index d427e287af8..30d63991ea0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1410,8 +1410,16 @@ DwarfDebug::collectVariableInfo(const MachineFunction *MF,
if (DV.getTag() == dwarf::DW_TAG_arg_variable &&
DISubprogram(DV.getContext()).describes(MF->getFunction()))
Scope = CurrentFnDbgScope;
- else
- Scope = findDbgScope(MInsn->getDebugLoc());
+ else {
+ if (DV.getVersion() <= LLVMDebugVersion9)
+ Scope = findDbgScope(MInsn->getDebugLoc());
+ else {
+ if (MDNode *IA = DV.getInlinedAt())
+ Scope = InlinedDbgScopeMap.lookup(DebugLoc::getFromDILocation(IA));
+ else
+ Scope = DbgScopeMap.lookup(cast<MDNode>(DV->getOperand(1)));
+ }
+ }
// If variable scope is not found then skip this variable.
if (!Scope)
continue;
OpenPOWER on IntegriCloud