================
@@ -69,8 +129,77 @@ void D(void) {
// CIR: %[[BLK2:.*]] = cir.block_address <@D, "LABEL_A"> : !cir.ptr<!void>
// CIR: cir.store align(8) %[[BLK2]], %[[PTR2]] : !cir.ptr<!void>,
!cir.ptr<!cir.ptr<!void>>
// CIR: cir.br ^bb1
-// CIR: ^bb1: // pred: ^bb0
+// CIR: ^bb1([[PHI:%*.]]: !cir.ptr<!void> {{.*}}): // pred: ^bb0
+// CIR: cir.indirectbr [[PHI]] : <!void>, [
+// CIR-DAG: ^bb2,
+// CIR-DAG: ^bb2,
+// CIR-DAG: ^bb2
+// CIR: ]
+// CIR: ^bb2: // 3 preds: ^bb1, ^bb1, ^bb1
// CIR: cir.label "LABEL_A"
// CIR: %[[BLK3:.*]] = cir.block_address <@D, "LABEL_A"> : !cir.ptr<!void>
// CIR: cir.store align(8) %[[BLK3]], %[[PTR3]] : !cir.ptr<!void>,
!cir.ptr<!cir.ptr<!void>>
// CIR: cir.return
+
+// OGCG: define dso_local void @D
+// OGCG: %[[PTR:.*]] = alloca ptr, align 8
+// OGCG: %[[PTR2:.*]] = alloca ptr, align 8
+// OGCG: %[[PTR3:.*]] = alloca ptr, align 8
+// OGCG: store ptr blockaddress(@D, %LABEL_A), ptr %[[PTR]], align 8
+// OGCG: store ptr blockaddress(@D, %LABEL_A), ptr %[[PTR2]], align 8
+// OGCG: %[[BLOCKADD:.*]] = load ptr, ptr %[[PTR2]], align 8
+// OGCG: br label %indirectgoto
+// OGCG: LABEL_A: ; preds =
%indirectgoto, %indirectgoto, %indirectgoto
+// OGCG: store ptr blockaddress(@D, %LABEL_A), ptr %[[PTR3]], align 8
+// OGCG: ret void
+// OGCG: indirectgoto: ; preds = %entry
+// OGCG: %indirect.goto.dest = phi ptr [ %[[BLOCKADD]], %entry ]
+// OGCG: indirectbr ptr %indirect.goto.dest, [label %LABEL_A, label
%LABEL_A, label %LABEL_A]
+
+// This test checks that CIR preserves insertion order of blockaddresses
+// for indirectbr, even if some were resolved immediately and others later.
+void E(void) {
+ void *ptr = &&LABEL_D;
+ void *ptr2 = &&LABEL_C;
+LABEL_A:
+LABEL_B:
+ void *ptr3 = &&LABEL_B;
+ void *ptr4 = &&LABEL_A;
+LABEL_C:
+LABEL_D:
+ return;
+}
+
+//CIR: cir.func dso_local @E()
----------------
Andres-Salamanca wrote:
Done
https://github.com/llvm/llvm-project/pull/169967
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits