[llvm] [IndVarSimplify] Allow predicateLoopExit on some loops with thread-local writes (PR #155901)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 23 01:18:53 PDT 2025
================
@@ -1704,6 +1709,27 @@ bool IndVarSimplify::optimizeLoopExits(Loop *L, SCEVExpander &Rewriter) {
return Changed;
}
+static bool crashingBBWithoutEffect(const BasicBlock &BB) {
+ return llvm::all_of(BB, [](const Instruction &I) {
+ // TODO: for now this is overly restrictive, to make sure nothing in this
+ // BB can depend on the loop body.
+ // It's not enough to check for !I.mayHaveSideEffects(), because e.g. a
+ // load does not have a side effect, but we could have
+ // %a = load ptr, ptr %ptr
+ // %b = load i32, ptr %a
+ // Now if the loop stored a non-nullptr to %a, we could cause a nullptr
+ // dereference by skipping over loop iterations.
----------------
nikic wrote:
Probably makes sense to skip doesNotAccessMemory() instructions?
https://github.com/llvm/llvm-project/pull/155901
More information about the llvm-commits
mailing list