summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2011-05-26 21:51:06 +0000
committerDevang Patel <dpatel@apple.com>2011-05-26 21:51:06 +0000
commit0da5250bcdafb4c1ca96e3811a98bd2f4a70bc25 (patch)
tree911c8e029de91832416e36a839fb69f5df529a0b /llvm/lib/Transforms
parent792ed4c616d77000149826e22b80168a4592462d (diff)
downloadbcm5719-llvm-0da5250bcdafb4c1ca96e3811a98bd2f4a70bc25.tar.gz
bcm5719-llvm-0da5250bcdafb4c1ca96e3811a98bd2f4a70bc25.zip
If llvm.dbg.value and the value instruction it refers to are far apart then iSel may not be able to find corresponding Node for llvm.dbg.value during DAG construction. Make iSel's life easier by removing this distance between llvm.dbg.value and its value instruction.
llvm-svn: 132151
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 483bfe36552..7ba92ba2565 100644
--- a/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/llvm/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -548,7 +548,19 @@ bool CodeGenPrepare::OptimizeCallInst(CallInst *CI) {
// From here on out we're working with named functions.
if (CI->getCalledFunction() == 0) return false;
-
+
+ // llvm.dbg.value is far away from the value then iSel may not be able
+ // handle it properly. iSel will drop llvm.dbg.value if it can not
+ // find a node corresponding to the value.
+ if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(CI))
+ if (Instruction *VI = dyn_cast_or_null<Instruction>(DVI->getValue()))
+ if (DVI->getParent() != VI->getParent() || DT->dominates(DVI, VI)) {
+ DEBUG(dbgs() << "Moving Debug Value before :\n" << *DVI << ' ' << *VI);
+ DVI->removeFromParent();
+ DVI->insertAfter(VI);
+ return true;
+ }
+
// We'll need TargetData from here on out.
const TargetData *TD = TLI ? TLI->getTargetData() : 0;
if (!TD) return false;
OpenPOWER on IntegriCloud