[clang] [CIR] Upstream support for break and continue statements (PR #134181)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 3 10:01:51 PDT 2025
================
@@ -265,3 +265,125 @@ void test_empty_while_true() {
// OGCG: br label %[[WHILE_BODY:.*]]
// OGCG: [[WHILE_BODY]]:
// OGCG: ret void
+
+void unreachable_after_continue() {
+ for (;;) {
+ continue;
+ int x = 1;
+ }
+}
+
+// CIR: cir.func @unreachable_after_continue
+// CIR: cir.scope {
+// CIR: cir.for : cond {
+// CIR: %[[TRUE:.*]] = cir.const #true
+// CIR: cir.condition(%[[TRUE]])
+// CIR: } body {
+// CIR: cir.scope {
+// CIR: %[[X:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["x", init] {alignment = 4 : i64}
+// CIR: cir.continue
+// CIR: ^bb1: // no predecessors
+// CIR: %[[ONE:.*]] = cir.const #cir.int<1> : !s32i
+// CIR: cir.store %[[ONE]], %[[X]] : !s32i, !cir.ptr<!s32i>
+// CIR: cir.yield
+// CIR: }
+// CIR: cir.yield
+// CIR: } step {
+// CIR: cir.yield
+// CIR: }
+// CIR: }
+// CIR: cir.return
+// CIR: }
+
+// LLVM: define void @unreachable_after_continue()
----------------
erichkeane wrote:
Can you run this and paste the CIR and outputted LLVM-IR here for me? I'm having a hard time visualizing from what you said.
https://github.com/llvm/llvm-project/pull/134181
More information about the cfe-commits
mailing list