[llvm] r317037 - loop-rotate: simplify code by using llvm::findDbgValues(). (NFC)
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 31 14:03:22 PDT 2017
Author: adrian
Date: Tue Oct 31 14:03:22 2017
New Revision: 317037
URL: http://llvm.org/viewvc/llvm-project?rev=317037&view=rev
Log:
loop-rotate: simplify code by using llvm::findDbgValues(). (NFC)
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=317037&r1=317036&r2=317037&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Tue Oct 31 14:03:22 2017
@@ -141,37 +141,29 @@ static void RewriteUsesOfClonedInstructi
// Replace MetadataAsValue(ValueAsMetadata(OrigHeaderVal)) uses in debug
// intrinsics.
- LLVMContext &C = OrigHeader->getContext();
- if (auto *VAM = ValueAsMetadata::getIfExists(OrigHeaderVal)) {
- if (auto *MAV = MetadataAsValue::getIfExists(C, VAM)) {
- for (auto UI = MAV->use_begin(), E = MAV->use_end(); UI != E;) {
- // Grab the use before incrementing the iterator. Otherwise, altering
- // the Use will invalidate the iterator.
- Use &U = *UI++;
- DbgInfoIntrinsic *UserInst = dyn_cast<DbgInfoIntrinsic>(U.getUser());
- if (!UserInst)
- continue;
+ SmallVector<DbgValueInst *, 1> DbgValues;
+ llvm::findDbgValues(DbgValues, OrigHeaderVal);
+ for (auto &DbgValue : DbgValues) {
+ // The original users in the OrigHeader are already using the original
+ // definitions.
+ BasicBlock *UserBB = DbgValue->getParent();
+ if (UserBB == OrigHeader)
+ continue;
- // The original users in the OrigHeader are already using the original
- // definitions.
- BasicBlock *UserBB = UserInst->getParent();
- if (UserBB == OrigHeader)
- continue;
-
- // Users in the OrigPreHeader need to use the value to which the
- // original definitions are mapped and anything else can be handled by
- // the SSAUpdater. To avoid adding PHINodes, check if the value is
- // available in UserBB, if not substitute undef.
- Value *NewVal;
- if (UserBB == OrigPreheader)
- NewVal = OrigPreHeaderVal;
- else if (SSA.HasValueForBlock(UserBB))
- NewVal = SSA.GetValueInMiddleOfBlock(UserBB);
- else
- NewVal = UndefValue::get(OrigHeaderVal->getType());
- U = MetadataAsValue::get(C, ValueAsMetadata::get(NewVal));
- }
- }
+ // Users in the OrigPreHeader need to use the value to which the
+ // original definitions are mapped and anything else can be handled by
+ // the SSAUpdater. To avoid adding PHINodes, check if the value is
+ // available in UserBB, if not substitute undef.
+ Value *NewVal;
+ if (UserBB == OrigPreheader)
+ NewVal = OrigPreHeaderVal;
+ else if (SSA.HasValueForBlock(UserBB))
+ NewVal = SSA.GetValueInMiddleOfBlock(UserBB);
+ else
+ NewVal = UndefValue::get(OrigHeaderVal->getType());
+ DbgValue->setOperand(0,
+ MetadataAsValue::get(OrigHeaderVal->getContext(),
+ ValueAsMetadata::get(NewVal)));
}
}
}
More information about the llvm-commits
mailing list