[clang] [KeyInstr][Clang] Do stmt atom (PR #134644)
Orlando Cazalet-Hyams via cfe-commits
cfe-commits at lists.llvm.org
Fri May 23 06:30:20 PDT 2025
================
@@ -1242,9 +1242,17 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S,
// As long as the condition is true, iterate the loop.
if (EmitBoolCondBranch) {
uint64_t BackedgeCount = getProfileCount(S.getBody()) - ParentCount;
- Builder.CreateCondBr(
+ auto *I = Builder.CreateCondBr(
BoolCondVal, LoopBody, LoopExit.getBlock(),
createProfileWeightsForLoop(S.getCond(), BackedgeCount));
+
+ // 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);
----------------
OCHyams wrote:
Done.
https://github.com/llvm/llvm-project/pull/134644
More information about the cfe-commits
mailing list