-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[NFC][PromoteMem2Reg] Move IncomingVals, IncomingLocs, Worklist into class #142468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Created using spr 1.3.6 [skip ci]
Created using spr 1.3.6
@llvm/pr-subscribers-llvm-transforms Author: Vitaly Buka (vitalybuka) Changes
On it's own the patch has no value, but it Full diff: https://github.com/llvm/llvm-project/pull/142468.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 62995e57b917c..9ddcbd516e00a 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -392,6 +392,15 @@ struct PromoteMem2Reg {
/// number.
SmallVector<unsigned> BBNumPreds;
+ /// The state of incoming values for the current DFS step.
+ RenamePassData::ValVector IncomingVals;
+
+ /// The state of incoming locations for the current DFS step.
+ RenamePassData::LocationVector IncomingLocs;
+
+ // DFS work stack.
+ SmallVector<RenamePassData, 8> WorkList;
+
/// Whether the function has the no-signed-zeros-fp-math attribute set.
bool NoSignedZeros = false;
@@ -423,10 +432,7 @@ struct PromoteMem2Reg {
void ComputeLiveInBlocks(AllocaInst *AI, AllocaInfo &Info,
const SmallPtrSetImpl<BasicBlock *> &DefBlocks,
SmallPtrSetImpl<BasicBlock *> &LiveInBlocks);
- void RenamePass(BasicBlock *BB, BasicBlock *Pred,
- RenamePassData::ValVector IncVals,
- RenamePassData::LocationVector IncLocs,
- std::vector<RenamePassData> &Worklist);
+ void RenamePass(BasicBlock *BB, BasicBlock *Pred);
bool QueuePhiNode(BasicBlock *BB, unsigned AllocaIdx, unsigned &Version);
/// Delete dbg.assigns that have been demoted to dbg.values.
@@ -438,6 +444,20 @@ struct PromoteMem2Reg {
DVR->eraseFromParent();
DVRAssignsToDelete.clear();
}
+
+ void pushToWorklist(BasicBlock *BB, BasicBlock *Pred,
+ RenamePassData::ValVector IncVals,
+ RenamePassData::LocationVector IncLocs) {
+ WorkList.emplace_back(BB, Pred, std::move(IncVals), std::move(IncLocs));
+ }
+
+ RenamePassData popFromWorklist() {
+ RenamePassData R = std::move(WorkList.back());
+ WorkList.pop_back();
+ IncomingVals = std::move(R.Values);
+ IncomingLocs = std::move(R.Locations);
+ return R;
+ }
};
} // end anonymous namespace
@@ -849,29 +869,26 @@ void PromoteMem2Reg::run() {
// Set the incoming values for the basic block to be null values for all of
// the alloca's. We do this in case there is a load of a value that has not
// been stored yet. In this case, it will get this null value.
- RenamePassData::ValVector Values(Allocas.size());
+ IncomingVals.assign(Allocas.size(), nullptr);
for (unsigned i = 0, e = Allocas.size(); i != e; ++i)
- Values[i] = UndefValue::get(Allocas[i]->getAllocatedType());
+ IncomingVals[i] = UndefValue::get(Allocas[i]->getAllocatedType());
// When handling debug info, treat all incoming values as if they have unknown
// locations until proven otherwise.
- RenamePassData::LocationVector Locations(Allocas.size());
+ IncomingLocs.assign(Allocas.size(), {});
// The renamer uses the Visited set to avoid infinite loops.
Visited.resize(F.getMaxBlockNumber());
// Walks all basic blocks in the function performing the SSA rename algorithm
// and inserting the phi nodes we marked as necessary
- std::vector<RenamePassData> RenamePassWorkList;
- RenamePassWorkList.emplace_back(&F.front(), nullptr, std::move(Values),
- std::move(Locations));
+ pushToWorklist(&F.front(), nullptr, std::move(IncomingVals),
+ std::move(IncomingLocs));
do {
- RenamePassData RPD = std::move(RenamePassWorkList.back());
- RenamePassWorkList.pop_back();
+ RenamePassData RPD = popFromWorklist();
// RenamePass may add new worklist entries.
- RenamePass(RPD.BB, RPD.Pred, std::move(RPD.Values),
- std::move(RPD.Locations), RenamePassWorkList);
- } while (!RenamePassWorkList.empty());
+ RenamePass(RPD.BB, RPD.Pred);
+ } while (!WorkList.empty());
// Remove the allocas themselves from the function.
for (Instruction *A : Allocas) {
@@ -1096,10 +1113,7 @@ static void updateForIncomingValueLocation(PHINode *PN, DebugLoc DL,
///
/// IncomingVals indicates what value each Alloca contains on exit from the
/// predecessor block Pred.
-void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
- RenamePassData::ValVector IncomingVals,
- RenamePassData::LocationVector IncomingLocs,
- std::vector<RenamePassData> &Worklist) {
+void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred) {
// If we are inserting any phi nodes into this BB, they will already be in the
// block.
if (PHINode *APN = dyn_cast<PHINode>(BB->begin())) {
@@ -1223,12 +1237,11 @@ void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
if (VisitedSuccs.insert(S).second) {
if (VisitedSuccs.size() == 1) {
// Let the first successor to own allocated arrays.
- Worklist.emplace_back(S, BB, std::move(IncomingVals),
- std::move(IncomingLocs));
+ pushToWorklist(S, BB, std::move(IncomingVals), std::move(IncomingLocs));
} else {
// Other successors have to make a copy.
- Worklist.emplace_back(S, BB, Worklist.back().Values,
- Worklist.back().Locations);
+ pushToWorklist(S, BB, WorkList.back().Values,
+ WorkList.back().Locations);
}
}
}
|
`IncomingVals`, `IncomingLocs`, `Worklist` into class members. They are all DFS state related, as `Visited`. But visited is already a class member. On it's own the patch has no value, but it simplify stuff in the next patch. Pull Request: llvm#142468
`IncomingVals`, `IncomingLocs`, `Worklist` into class members. They are all DFS state related, as `Visited`. But visited is already a class member. On it's own the patch has no value, but it simplify stuff in the next patch. Pull Request: llvm#142468
Created using spr 1.3.6 [skip ci]
Created using spr 1.3.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with context of the follow up. By itself, this patch is probably making things worse
Yes, Incoming* here are better as parameters. I will wait with landing for #142474 accepted |
Created using spr 1.3.6 [skip ci]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Created using spr 1.3.6 [skip ci]
Created using spr 1.3.6 [skip ci]
`IncomingVals`, `IncomingLocs`, `Worklist` into class members. They are all DFS state related, as `Visited`. But visited is already a class member. On it's own the patch has no value, but it simplify stuff in the next patch. Pull Request: llvm#142468
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/138/builds/14052 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/206/builds/1269 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/11222 Here is the relevant piece of the build log for the reference
|
They are all DFS state related, as
Visited
. ButVisited
is already aclass member, so we make things more consistent and less
parameters to pass around.
On it's own the patch has little value, but it simplify stuff in the #142474.
For #142461