aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2020-07-28 09:48:47 -0500
committerJohannes Doerfert <johannes@jdoerfert.de>2020-07-28 17:41:01 -0500
commit450dc09d69df343386865d279983de9d51d1e984 (patch)
tree979a78614f64545cb253d57622fce0de17d13196 /llvm/lib/IR/Value.cpp
parent417d3d495f1cfb0a2f7b60d00829925126fdcfd9 (diff)
downloadllvm-450dc09d69df343386865d279983de9d51d1e984.zip
llvm-450dc09d69df343386865d279983de9d51d1e984.tar.gz
llvm-450dc09d69df343386865d279983de9d51d1e984.tar.bz2
[SROA][Mem2Reg] Use efficient droppable use API (after D83976)
Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D84804
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 8c1f9c5..26a9835 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -175,25 +175,34 @@ void Value::dropDroppableUses(
for (Use &U : uses())
if (U.getUser()->isDroppable() && ShouldDrop(&U))
ToBeEdited.push_back(&U);
- for (Use *U : ToBeEdited) {
- U->removeFromList();
- if (auto *Assume = dyn_cast<IntrinsicInst>(U->getUser())) {
- assert(Assume->getIntrinsicID() == Intrinsic::assume);
- unsigned OpNo = U->getOperandNo();
- if (OpNo == 0)
- Assume->setOperand(0, ConstantInt::getTrue(Assume->getContext()));
- else {
- Assume->setOperand(OpNo, UndefValue::get(U->get()->getType()));
- CallInst::BundleOpInfo &BOI = Assume->getBundleOpInfoForOperand(OpNo);
- BOI.Tag = getContext().pImpl->getOrInsertBundleTag("ignore");
- }
- } else
- llvm_unreachable("unkown droppable use");
+ for (Use *U : ToBeEdited)
+ dropDroppableUse(*U);
+}
+
+void Value::dropDroppableUsesIn(User &Usr) {
+ assert(Usr.isDroppable() && "Expected a droppable user!");
+ for (Use &UsrOp : Usr.operands()) {
+ if (UsrOp.get() == this)
+ dropDroppableUse(UsrOp);
}
}
-void Value::dropDroppableUsesByUser(const User &Usr) {
- dropDroppableUses([&](const Use *U) { return U->getUser() == &Usr; });
+void Value::dropDroppableUse(Use &U) {
+ U.removeFromList();
+ if (auto *Assume = dyn_cast<IntrinsicInst>(U.getUser())) {
+ assert(Assume->getIntrinsicID() == Intrinsic::assume);
+ unsigned OpNo = U.getOperandNo();
+ if (OpNo == 0)
+ U.set(ConstantInt::getTrue(Assume->getContext()));
+ else {
+ U.set(UndefValue::get(U.get()->getType()));
+ CallInst::BundleOpInfo &BOI = Assume->getBundleOpInfoForOperand(OpNo);
+ BOI.Tag = getContext().pImpl->getOrInsertBundleTag("ignore");
+ }
+ return;
+ }
+
+ llvm_unreachable("unkown droppable use");
}
bool Value::isUsedInBasicBlock(const BasicBlock *BB) const {