diff options
| author | Vedant Kumar <vsk@apple.com> | 2018-01-25 21:37:05 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2018-01-25 21:37:05 +0000 |
| commit | 6bfc869cf76a0ff91fd8cda8dfc454f4ef46fa84 (patch) | |
| tree | 5422f5be230ae7de5f2724b3da2dc14bcc9ed44d /llvm/lib/Transforms/Scalar | |
| parent | 31475a039a629f575f828c0c9bdc7a7d98e662b4 (diff) | |
| download | bcm5719-llvm-6bfc869cf76a0ff91fd8cda8dfc454f4ef46fa84.tar.gz bcm5719-llvm-6bfc869cf76a0ff91fd8cda8dfc454f4ef46fa84.zip | |
[Debug] Add a utility to propagate dbg.value to new PHIs, NFC
This simply moves an existing utility to Utils for reuse.
Split out of: https://reviews.llvm.org/D42551
Patch by Matt Davis!
llvm-svn: 323471
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopRotation.cpp | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index 0f35fccbe66..c263d5bc8be 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -169,38 +169,6 @@ static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader, } } -/// Propagate dbg.value intrinsics through the newly inserted Phis. -static void insertDebugValues(BasicBlock *OrigHeader, - SmallVectorImpl<PHINode*> &InsertedPHIs) { - ValueToValueMapTy DbgValueMap; - - // Map existing PHI nodes to their dbg.values. - for (auto &I : *OrigHeader) { - if (auto DbgII = dyn_cast<DbgInfoIntrinsic>(&I)) { - if (auto *Loc = dyn_cast_or_null<PHINode>(DbgII->getVariableLocation())) - DbgValueMap.insert({Loc, DbgII}); - } - } - - // Then iterate through the new PHIs and look to see if they use one of the - // previously mapped PHIs. If so, insert a new dbg.value intrinsic that will - // propagate the info through the new PHI. - LLVMContext &C = OrigHeader->getContext(); - for (auto PHI : InsertedPHIs) { - for (auto VI : PHI->operand_values()) { - auto V = DbgValueMap.find(VI); - if (V != DbgValueMap.end()) { - auto *DbgII = cast<DbgInfoIntrinsic>(V->second); - Instruction *NewDbgII = DbgII->clone(); - auto PhiMAV = MetadataAsValue::get(C, ValueAsMetadata::get(PHI)); - NewDbgII->setOperand(0, PhiMAV); - BasicBlock *Parent = PHI->getParent(); - NewDbgII->insertBefore(Parent->getFirstNonPHIOrDbgOrLifetime()); - } - } - } -} - /// Rotate loop LP. Return true if the loop is rotated. /// /// \param SimplifiedLatch is true if the latch was just folded into the final @@ -405,7 +373,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // previously had debug metadata attached. This keeps the debug info // up-to-date in the loop body. if (!InsertedPHIs.empty()) - insertDebugValues(OrigHeader, InsertedPHIs); + insertDebugValuesForPHIs(OrigHeader, InsertedPHIs); // NewHeader is now the header of the loop. L->moveToHeader(NewHeader); |

