diff options
author | Nico Weber <nicolasweber@gmx.de> | 2017-03-07 17:23:52 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2017-03-07 17:23:52 +0000 |
commit | 3b2f0094d7559823697e4724c717f3e3fa4b5e94 (patch) | |
tree | 29f2dfc853062505a54e51d277ada4b48e492176 /llvm/lib | |
parent | 6c9958e0b3ea79cef61882217305c82b292946fe (diff) | |
download | bcm5719-llvm-3b2f0094d7559823697e4724c717f3e3fa4b5e94.tar.gz bcm5719-llvm-3b2f0094d7559823697e4724c717f3e3fa4b5e94.zip |
Revert r297132, it caused PR32171
llvm-svn: 297159
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopRotation.cpp | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index f35cb88d17c..0d57ce1e827 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -79,8 +79,7 @@ private: /// to merge the two values. Do this now. static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader, BasicBlock *OrigPreheader, - ValueToValueMapTy &ValueMap, - SmallVectorImpl<PHINode*> *InsertedPHIs) { + ValueToValueMapTy &ValueMap) { // Remove PHI node entries that are no longer live. BasicBlock::iterator I, E = OrigHeader->end(); for (I = OrigHeader->begin(); PHINode *PN = dyn_cast<PHINode>(I); ++I) @@ -88,7 +87,7 @@ static void RewriteUsesOfClonedInstructions(BasicBlock *OrigHeader, // Now fix up users of the instructions in OrigHeader, inserting PHI nodes // as necessary. - SSAUpdater SSA(InsertedPHIs); + SSAUpdater SSA; for (I = OrigHeader->begin(); I != E; ++I) { Value *OrigHeaderVal = &*I; @@ -175,38 +174,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 (isa<PHINode>(DbgII->getVariableLocation())) - DbgValueMap.insert({DbgII->getVariableLocation(), 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 = dyn_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 @@ -380,18 +347,9 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // remove the corresponding incoming values from the PHI nodes in OrigHeader. LoopEntryBranch->eraseFromParent(); - - SmallVector<PHINode*, 2> InsertedPHIs; // If there were any uses of instructions in the duplicated block outside the // loop, update them, inserting PHI nodes as required - RewriteUsesOfClonedInstructions(OrigHeader, OrigPreheader, ValueMap, - &InsertedPHIs); - - // Attach dbg.value intrinsics to the new phis if that phi uses a value that - // previously had debug metadata attached. This keeps the debug info - // up-to-date in the loop body. - if (!InsertedPHIs.empty()) - insertDebugValues(OrigHeader, InsertedPHIs); + RewriteUsesOfClonedInstructions(OrigHeader, OrigPreheader, ValueMap); // NewHeader is now the header of the loop. L->moveToHeader(NewHeader); |