-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[Transforms] Use llvm::append_range (NFC) #133650
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
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_append_range_insert_llvm_Transforms
Mar 30, 2025
Merged
[Transforms] Use llvm::append_range (NFC) #133650
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_append_range_insert_llvm_Transforms
Mar 30, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-pgo @llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/133650.diff 5 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index f5ae204426170..df1f6fddeba60 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -2286,8 +2286,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy,
std::vector<CallInfo> AllCalls;
AllCalls.reserve(Node->MatchingCalls.size() + 1);
AllCalls.push_back(Node->Call);
- AllCalls.insert(AllCalls.end(), Node->MatchingCalls.begin(),
- Node->MatchingCalls.end());
+ llvm::append_range(AllCalls, Node->MatchingCalls);
// First see if we can partition the calls by callee function, creating new
// nodes to host each set of calls calling the same callees. This is
@@ -2468,9 +2467,8 @@ bool CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::partitionCallsByCallee(
// The first call becomes the primary call for this caller node, and the
// rest go in the matching calls list.
Info->Node->setCall(Info->Calls.front());
- Info->Node->MatchingCalls.insert(Info->Node->MatchingCalls.end(),
- Info->Calls.begin() + 1,
- Info->Calls.end());
+ llvm::append_range(Info->Node->MatchingCalls,
+ llvm::drop_begin(Info->Calls));
// Save the primary call to node correspondence so that we can update
// the NonAllocationCallToContextNodeMap, which is being iterated in the
// caller of this function.
@@ -4117,8 +4115,7 @@ bool CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::assignFunctions() {
// Ignore original Node if we moved all of its contexts to clones.
if (!Node->emptyContextIds())
ClonesWorklist.push_back(Node);
- ClonesWorklist.insert(ClonesWorklist.end(), Node->Clones.begin(),
- Node->Clones.end());
+ llvm::append_range(ClonesWorklist, Node->Clones);
// Now walk through all of the clones of this callsite Node that we need,
// and determine the assignment to a corresponding clone of the current
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 82434680b8f23..938aab5879044 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -399,7 +399,7 @@ struct ThreadingPath {
void push_back(BasicBlock *BB) { Path.push_back(BB); }
void push_front(BasicBlock *BB) { Path.push_front(BB); }
void appendExcludingFirst(const PathType &OtherPath) {
- Path.insert(Path.end(), OtherPath.begin() + 1, OtherPath.end());
+ llvm::append_range(Path, llvm::drop_begin(OtherPath));
}
void print(raw_ostream &OS) const {
diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 4f7956514b7b5..4c6f6f12d7138 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -3641,14 +3641,12 @@ static bool unswitchLoop(Loop &L, DominatorTree &DT, LoopInfo &LI,
}
// Next check all loops nested within L.
SmallVector<const Loop *, 4> Worklist;
- Worklist.insert(Worklist.end(), L->getSubLoops().begin(),
- L->getSubLoops().end());
+ llvm::append_range(Worklist, L->getSubLoops());
while (!Worklist.empty()) {
auto *CurLoop = Worklist.pop_back_val();
if (!PSI->isColdBlock(CurLoop->getHeader(), BFI))
return false;
- Worklist.insert(Worklist.end(), CurLoop->getSubLoops().begin(),
- CurLoop->getSubLoops().end());
+ llvm::append_range(Worklist, CurLoop->getSubLoops());
}
return true;
};
diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp
index baaad8bb48f33..c76b3afef50c2 100644
--- a/llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -387,7 +387,7 @@ struct ChainEdge {
void appendJump(JumpT *Jump) { Jumps.push_back(Jump); }
void moveJumps(ChainEdge *Other) {
- Jumps.insert(Jumps.end(), Other->Jumps.begin(), Other->Jumps.end());
+ llvm::append_range(Jumps, Other->Jumps);
Other->Jumps.clear();
Other->Jumps.shrink_to_fit();
}
diff --git a/llvm/lib/Transforms/Utils/SampleProfileInference.cpp b/llvm/lib/Transforms/Utils/SampleProfileInference.cpp
index 54d46117729c9..53bcaa6d3df03 100644
--- a/llvm/lib/Transforms/Utils/SampleProfileInference.cpp
+++ b/llvm/lib/Transforms/Utils/SampleProfileInference.cpp
@@ -672,8 +672,8 @@ class FlowAdjuster {
// Concatenate the two paths
std::vector<FlowJump *> Result;
- Result.insert(Result.end(), ForwardPath.begin(), ForwardPath.end());
- Result.insert(Result.end(), BackwardPath.begin(), BackwardPath.end());
+ llvm::append_range(Result, ForwardPath);
+ llvm::append_range(Result, BackwardPath);
return Result;
}
|
kuhar
approved these changes
Mar 30, 2025
SchrodingerZhu
pushed a commit
to SchrodingerZhu/llvm-project
that referenced
this pull request
Mar 31, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.