[llvm-branch-commits] [clang] [KeyInstr][Clang] For stmt atom (PR #134646)

Jeremy Morse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu May 22 17:00:38 PDT 2025


================
@@ -1362,7 +1363,14 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
       BoolCondVal = emitCondLikelihoodViaExpectIntrinsic(
           BoolCondVal, Stmt::getLikelihood(S.getBody()));
 
-    Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+    auto *I = Builder.CreateCondBr(BoolCondVal, ForBody, ExitBlock, Weights);
+    // Key Instructions: Emit the condition and branch as separate atoms to
+    // match existing loop stepping behaviour. FIXME: We could have the branch
+    // as the backup location for the condition, which would probably be a
+    // better experience (no jumping to the brace).
+    if (auto *I = dyn_cast<llvm::Instruction>(BoolCondVal))
+      addInstToNewSourceAtom(I, nullptr);
----------------
jmorse wrote:

As with prior patches, pls2rename `I` to not shadow the outer `I`

https://github.com/llvm/llvm-project/pull/134646


More information about the llvm-branch-commits mailing list