[llvm] 8e62968 - [Attributor] Identify dead uses in PHIs (almost) based on dead edges
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 13:19:06 PST 2020
Author: Johannes Doerfert
Date: 2020-02-11T15:11:55-06:00
New Revision: 8e62968d45429815411ca9bb358a913dde7b1152
URL: https://github.com/llvm/llvm-project/commit/8e62968d45429815411ca9bb358a913dde7b1152
DIFF: https://github.com/llvm/llvm-project/commit/8e62968d45429815411ca9bb358a913dde7b1152.diff
LOG: [Attributor] Identify dead uses in PHIs (almost) based on dead edges
As an approximation to a dead edge we can check if the terminator is
dead. If so, the corresponding operand use in a PHI node is dead even if
the PHI node itself is not.
Added:
Modified:
llvm/lib/Transforms/IPO/Attributor.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 4c0185de3f04..877557a92fb5 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -6489,14 +6489,27 @@ bool Attributor::checkForAllUses(
const Use *U = Worklist.pop_back_val();
if (!Visited.insert(U).second)
continue;
- LLVM_DEBUG(dbgs() << "[Attributor] Check use: " << **U << "\n");
- if (Instruction *UserI = dyn_cast<Instruction>(U->getUser()))
- if (LivenessAA && LivenessAA->isAssumedDead(UserI)) {
- LLVM_DEBUG(dbgs() << "[Attributor] Dead user: " << *UserI << ": "
- << *LivenessAA << "\n");
- AnyDead = true;
- continue;
+ LLVM_DEBUG(dbgs() << "[Attributor] Check use: " << **U << " [" << LivenessAA
+ << "]\n");
+ if (LivenessAA) {
+ if (Instruction *UserI = dyn_cast<Instruction>(U->getUser())) {
+ if (LivenessAA->isAssumedDead(UserI)) {
+ LLVM_DEBUG(dbgs() << "[Attributor] Dead user: " << *UserI << ": "
+ << *LivenessAA << "\n");
+ AnyDead = true;
+ continue;
+ }
+ if (PHINode *PHI = dyn_cast<PHINode>(UserI)) {
+ BasicBlock *IncomingBB = PHI->getIncomingBlock(*U);
+ if (LivenessAA->isAssumedDead(IncomingBB->getTerminator())) {
+ LLVM_DEBUG(dbgs() << "[Attributor] Dead user: " << *UserI << ": "
+ << *LivenessAA << "\n");
+ AnyDead = true;
+ continue;
+ }
+ }
}
+ }
bool Follow = false;
if (!Pred(*U, Follow))
More information about the llvm-commits
mailing list