Skip to content

[Transforms] Use a range-based for loop (NFC) #105769

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Aug 23, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/105769.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp (+2-5)
diff --git a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
index 77d67a2ce0f380..1f9c3837cc06dc 100644
--- a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
+++ b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
@@ -331,12 +331,9 @@ bool PlaceSafepointsPass::runImpl(Function &F, const TargetLibraryInfo &TLI) {
         // and b) edges to distinct loop headers.  We need to insert pools on
         // each.
         SetVector<BasicBlock *> Headers;
-        for (unsigned i = 0; i < Term->getNumSuccessors(); i++) {
-          BasicBlock *Succ = Term->getSuccessor(i);
-          if (DT.dominates(Succ, Term->getParent())) {
+        for (BasicBlock *Succ : successors(Term->getParent()))
+          if (DT.dominates(Succ, Term->getParent()))
             Headers.insert(Succ);
-          }
-        }
         assert(!Headers.empty() && "poll location is not a loop latch?");
 
         // The split loop structure here is so that we only need to recalculate

@kazutakahirata kazutakahirata merged commit 0d1d95e into llvm:main Aug 23, 2024
8 of 10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_for_Transforms branch August 23, 2024 12:56
cjdb pushed a commit to cjdb/llvm-project that referenced this pull request Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants