aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-09-16 20:39:11 +0000
committerDevang Patel <dpatel@apple.com>2009-09-16 20:39:11 +0000
commit123eaa71b50f5ac2ea2233685baedddbb72f387b (patch)
tree4f1f6f40b8c9d4dabaf21095ce34d9eed10f7eea
parent6f65d79750154c92c3e184c8cf3233a66c411c87 (diff)
At iSel time, update DebugLoc based on debug info attached with an instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82077 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 8eb16e5483..f905890fa2 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -16,6 +16,7 @@
#include "SelectionDAGBuild.h"
#include "llvm/CodeGen/SelectionDAGISel.h"
#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/ANalysis/DebugInfo.h"
#include "llvm/Constants.h"
#include "llvm/CallingConv.h"
#include "llvm/DerivedTypes.h"
@@ -370,12 +371,25 @@ void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB,
BasicBlock::iterator Begin,
BasicBlock::iterator End) {
SDL->setCurrentBasicBlock(BB);
+ Metadata &TheMetadata = LLVMBB->getParent()->getContext().getMetadata();
+ MDKindID MDDbgKind = TheMetadata.getMDKind("dbg");
// Lower all of the non-terminator instructions. If a call is emitted
// as a tail call, cease emitting nodes for this block.
- for (BasicBlock::iterator I = Begin; I != End && !SDL->HasTailCall; ++I)
+ for (BasicBlock::iterator I = Begin; I != End && !SDL->HasTailCall; ++I) {
+ if (MDDbgKind) {
+ // Update DebugLoc if debug information is attached with this
+ // instruction.
+ if (MDNode *Dbg =
+ dyn_cast_or_null<MDNode>(TheMetadata.getMD(MDDbgKind, I))) {
+ DILocation DILoc(Dbg);
+ DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo());
+ SDL->setCurDebugLoc(Loc);
+ }
+ }
if (!isa<TerminatorInst>(I))
SDL->visit(*I);
+ }
if (!SDL->HasTailCall) {
// Ensure that all instructions which are used outside of their defining
@@ -640,6 +654,9 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
#endif
);
+ Metadata &TheMetadata = Fn.getContext().getMetadata();
+ MDKindID MDDbgKind = TheMetadata.getMDKind("dbg");
+
// Iterate over all basic blocks in the function.
for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) {
BasicBlock *LLVMBB = &*I;
@@ -722,6 +739,18 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
FastIS->startNewBlock(BB);
// Do FastISel on as many instructions as possible.
for (; BI != End; ++BI) {
+ if (MDDbgKind) {
+ // Update DebugLoc if debug information is attached with this
+ // instruction.
+ if (MDNode *Dbg =
+ dyn_cast_or_null<MDNode>(TheMetadata.getMD(MDDbgKind, BI))) {
+ DILocation DILoc(Dbg);
+ DebugLoc Loc = ExtractDebugLocation(DILoc,
+ MF.getDebugLocInfo());
+ FastIS->setCurDebugLoc(Loc);
+ }
+ }
+
// Just before the terminator instruction, insert instructions to
// feed PHI nodes in successor blocks.
if (isa<TerminatorInst>(BI))