[llvm] 2248cdf - [Arm] Fix UAF in ARMConstantIslandPass (#146232)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 28 21:20:33 PDT 2025
Author: Qinkun Bao
Date: 2025-06-29T00:20:29-04:00
New Revision: 2248cdfa74ecc09bca2a142029cc4c96e5d00cda
URL: https://github.com/llvm/llvm-project/commit/2248cdfa74ecc09bca2a142029cc4c96e5d00cda
DIFF: https://github.com/llvm/llvm-project/commit/2248cdfa74ecc09bca2a142029cc4c96e5d00cda.diff
LOG: [Arm] Fix UAF in ARMConstantIslandPass (#146232)
https://github.com/llvm/llvm-project/pull/146198 changes
```
for (unsigned i = 0, e = ImmBranches.size(); i != e; ++i)
BRChange |= fixupImmediateBr(ImmBranches[i]);
```
to
```
for (ImmBranch &Br : ImmBranches)
BRChange |= fixupImmediateBr(Br);
```
Unfortunately, they are not NFC and cause the buildbot error. e.g.,
https://lab.llvm.org/buildbot/#/builders/24/builds/9943
https://lab.llvm.org/buildbot/#/builders/169/builds/12570
Use make_early_inc_range to fix the issue
Added:
Modified:
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
index e72aa8ef051cd..d96b47ffd0c6c 100644
--- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
+++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
@@ -476,7 +476,7 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
LLVM_DEBUG(dbgs() << "Beginning BR iteration #" << NoBRIters << '\n');
bool BRChange = false;
- for (ImmBranch &Br : ImmBranches)
+ for (ImmBranch &Br : llvm::make_early_inc_range(ImmBranches))
BRChange |= fixupImmediateBr(Br);
if (BRChange && ++NoBRIters > 30)
report_fatal_error("Branch Fix Up pass failed to converge!");
More information about the llvm-commits
mailing list