[llvm] [LoopUnroll] Introduce UnrollMaxIterations as a hard cap on how many iterations we try to unroll (PR #78648)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 23 11:35:49 PST 2024
================
@@ -453,6 +457,14 @@ LoopUnrollResult llvm::UnrollLoop(Loop *L, UnrollLoopOptions ULO, LoopInfo *LI,
}
}
+ // Certain cases with UBSAN can cause trip count to be calculated as INT_MAX,
+ // Block unrolling at a reasonable limit so that the compiler doesn't hang
+ // trying to unroll the loop. See PR77842
+ if (ULO.Count > UnrollMaxIterations) {
+ LLVM_DEBUG(dbgs() << "Won't unroll; trip count is too large\n");
+ return LoopUnrollResult::Unmodified;
+ }
----------------
nikic wrote:
This check should be in Scalar/LoopUnrollPass, not Utils/LoopUnroll. That's where all the other unroll count thresholds are implemented.
https://github.com/llvm/llvm-project/pull/78648
More information about the llvm-commits
mailing list