diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-11-02 23:17:06 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-11-02 23:17:06 +0000 |
commit | fbb6fbf709fbf22bd516c99ef17810c579014d11 (patch) | |
tree | 71b4e41a64ccf212eb433f734ae5d940787a3248 /llvm/lib/Transforms | |
parent | 6fe84be9a38f1bbe0fc0cd01b7fb1685521a3859 (diff) | |
download | bcm5719-llvm-fbb6fbf709fbf22bd516c99ef17810c579014d11.tar.gz bcm5719-llvm-fbb6fbf709fbf22bd516c99ef17810c579014d11.zip |
IndVarSimplify: preserve debug information attached to widened PHI nodes.
This fixes PR35015.
https://bugs.llvm.org/show_bug.cgi?id=35015
Differential Revision: https://reviews.llvm.org/D39345
llvm-svn: 317282
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 9ce42a06825..abb50f27f1c 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -48,6 +48,7 @@ #include "llvm/IR/ConstantRange.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" @@ -1624,6 +1625,15 @@ PHINode *WidenIV::createWideIV(SCEVExpander &Rewriter) { if (DU.NarrowDef->use_empty()) DeadInsts.emplace_back(DU.NarrowDef); } + + // Attach any debug information to the new PHI. Since OrigPhi and WidePHI + // evaluate the same recurrence, we can just copy the debug info over. + SmallVector<DbgValueInst *, 1> DbgValues; + llvm::findDbgValues(DbgValues, OrigPhi); + auto *MDPhi = MetadataAsValue::get(WidePhi->getContext(), + ValueAsMetadata::get(WidePhi)); + for (auto &DbgValue : DbgValues) + DbgValue->setOperand(0, MDPhi); return WidePhi; } |