[llvm-commits] [llvm] r83189 - in /llvm/trunk: include/llvm/CodeGen/MachineModuleInfo.h lib/CodeGen/SelectionDAG/FastISel.cpp
Devang Patel
dpatel at apple.com
Wed Sep 30 18:03:26 PDT 2009
Author: dpatel
Date: Wed Sep 30 20:03:26 2009
New Revision: 83189
URL: http://llvm.org/viewvc/llvm-project?rev=83189&view=rev
Log:
If location info is attached with an instruction then keep track of alloca slots used by a variable. This info will be used by AsmPrinter to emit debug info for variables.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=83189&r1=83188&r2=83189&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Wed Sep 30 20:03:26 2009
@@ -48,6 +48,7 @@
//===----------------------------------------------------------------------===//
// Forward declarations.
class Constant;
+class MDNode;
class GlobalVariable;
class MachineBasicBlock;
class MachineFunction;
@@ -142,9 +143,13 @@
/// DbgInfoAvailable - True if debugging information is available
/// in this module.
bool DbgInfoAvailable;
+
public:
static char ID; // Pass identification, replacement for typeid
+ typedef DenseMap<MDNode *, std::pair<MDNode *, unsigned> > VariableDbgInfoMapTy;
+ VariableDbgInfoMapTy VariableDbgInfo;
+
MachineModuleInfo();
~MachineModuleInfo();
@@ -325,6 +330,15 @@
/// of one is required to emit exception handling info.
Function *getPersonality() const;
+ /// setVariableDbgInfo - Collect information used to emit debugging information
+ /// of a variable.
+ void setVariableDbgInfo(MDNode *N, MDNode *L, unsigned S) {
+ if (N && L)
+ VariableDbgInfo[N] = std::make_pair(L, S);
+ }
+
+ VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; }
+
}; // End class MachineModuleInfo
} // End llvm namespace
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=83189&r1=83188&r2=83189&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Sep 30 20:03:26 2009
@@ -407,7 +407,6 @@
|| !DW->ShouldEmitDwarfDebug())
return true;
- Value *Variable = DI->getVariable();
Value *Address = DI->getAddress();
if (BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
Address = BCI->getOperand(0);
@@ -418,8 +417,15 @@
StaticAllocaMap.find(AI);
if (SI == StaticAllocaMap.end()) break; // VLAs.
int FI = SI->second;
-
- DW->RecordVariable(cast<MDNode>(Variable), FI);
+ if (MMI) {
+ MetadataContext &TheMetadata = AI->getContext().getMetadata();
+ unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
+ MDNode *AllocaLocation =
+ dyn_cast_or_null<MDNode>(TheMetadata.getMD(MDDbgKind, AI));
+ if (AllocaLocation)
+ MMI->setVariableDbgInfo(DI->getVariable(), AllocaLocation, FI);
+ }
+ DW->RecordVariable(DI->getVariable(), FI);
return true;
}
case Intrinsic::eh_exception: {
More information about the llvm-commits
mailing list