[PATCH] D93810: [RS4GC] Lazily set changed flag when folding single entry phis
Yevgeny Rouban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 25 02:58:47 PST 2020
yrouban created this revision.
yrouban added reviewers: apilipenko, reames.
Herald added subscribers: dantrushin, hiraditya.
yrouban requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The function //FoldSingleEntryPHINodes()// is changed to return if it has changed IR or not. This return value is used by RS4GC to set the //MadeChange// flag respectively.
The change is simple. No test is needed.
https://reviews.llvm.org/D93810
Files:
llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
===================================================================
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -136,9 +136,10 @@
return !DeadBlocks.empty();
}
-void llvm::FoldSingleEntryPHINodes(BasicBlock *BB,
+bool llvm::FoldSingleEntryPHINodes(BasicBlock *BB,
MemoryDependenceResults *MemDep) {
- if (!isa<PHINode>(BB->begin())) return;
+ if (!isa<PHINode>(BB->begin()))
+ return false;
while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
if (PN->getIncomingValue(0) != PN)
@@ -151,6 +152,7 @@
PN->eraseFromParent();
}
+ return true;
}
bool llvm::DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI,
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -2736,10 +2736,8 @@
// of liveness sets for no good reason. It may be harder to do this post
// insertion since relocations and base phis can confuse things.
for (BasicBlock &BB : F)
- if (BB.getUniquePredecessor()) {
- MadeChange = true;
- FoldSingleEntryPHINodes(&BB);
- }
+ if (BB.getUniquePredecessor())
+ MadeChange |= FoldSingleEntryPHINodes(&BB);
// Before we start introducing relocations, we want to tweak the IR a bit to
// avoid unfortunate code generation effects. The main example is that we
Index: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
===================================================================
--- llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
+++ llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h
@@ -74,7 +74,7 @@
/// in it, fold them away. This handles the case when all entries to the PHI
/// nodes in a block are guaranteed equal, such as when the block has exactly
/// one predecessor.
-void FoldSingleEntryPHINodes(BasicBlock *BB,
+bool FoldSingleEntryPHINodes(BasicBlock *BB,
MemoryDependenceResults *MemDep = nullptr);
/// Examine each PHI in the given block and delete it if it is dead. Also
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93810.313724.patch
Type: text/x-patch
Size: 2280 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201225/feda6645/attachment.bin>
More information about the llvm-commits
mailing list