summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2018-12-10 22:17:04 +0000
committerDavide Italiano <davide@freebsd.org>2018-12-10 22:17:04 +0000
commit8ec7709f58a087449f68be0f4eec62251bacba97 (patch)
tree4c0c6b4c8cbd70789a89f9e7948c8ad78b54da1b /llvm/lib/Transforms
parent588232858edb8aa2aae4bf8246a6f5d7db598534 (diff)
downloadbcm5719-llvm-8ec7709f58a087449f68be0f4eec62251bacba97.tar.gz
bcm5719-llvm-8ec7709f58a087449f68be0f4eec62251bacba97.zip
[Local] Promote an utility that could be used elsewhere. NFCI.
llvm-svn: 348804
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp8
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp11
2 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 61b6d7ca259..cb893eab165 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -789,13 +789,7 @@ void ReassociatePass::RewriteExprTree(BinaryOperator *I,
// Discard any debug info related to the expressions that has changed (we
// can leave debug infor related to the root, since the result of the
// expression tree should be the same even after reassociation).
- SmallVector<DbgVariableIntrinsic *, 1> DbgUsers;
- findDbgUsers(DbgUsers, ExpressionChanged);
- for (auto *DII : DbgUsers) {
- Value *Undef = UndefValue::get(ExpressionChanged->getType());
- DII->setOperand(0, MetadataAsValue::get(DII->getContext(),
- ValueAsMetadata::get(Undef)));
- }
+ replaceDbgUsesWithUndef(ExpressionChanged);
ExpressionChanged->moveBefore(I);
ExpressionChanged = cast<BinaryOperator>(*ExpressionChanged->user_begin());
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index d9e0c15dda3..2b7d7ad9d4d 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -476,6 +476,17 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(
}
}
+bool llvm::replaceDbgUsesWithUndef(Instruction *I) {
+ SmallVector<DbgVariableIntrinsic *, 1> DbgUsers;
+ findDbgUsers(DbgUsers, I);
+ for (auto *DII : DbgUsers) {
+ Value *Undef = UndefValue::get(I->getType());
+ DII->setOperand(0, MetadataAsValue::get(DII->getContext(),
+ ValueAsMetadata::get(Undef)));
+ }
+ return !DbgUsers.empty();
+}
+
/// areAllUsesEqual - Check whether the uses of a value are all the same.
/// This is similar to Instruction::hasOneUse() except this will also return
/// true when there are no uses or multiple uses that all refer to the same
OpenPOWER on IntegriCloud