[clang] [CIR] Only scan globals and constants for block addresses in GotoSolver (PR #232870)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 16 16:54:43 PDT 2026
================
@@ -88,3 +90,64 @@ cir.func @d() {
// CHECK: cir.indirect_br %[[DEST]] : !cir.ptr<!void>, [
// CHECK: ^[[L1BB]]
// CHECK: ]
+
+cir.func @e() {
+ %0 = cir.alloca "ptr" align(8) init : !cir.ptr<!cir.ptr<!void>>
+ %1 = cir.block_address <@e, "a"> : !cir.ptr<!void>
+ %2 = cir.const #cir.block_addr_info<@e, "b"> : !cir.ptr<!void>
+ cir.store align(8) %1, %0 : !cir.ptr<!void>, !cir.ptr<!cir.ptr<!void>>
+ %3 = cir.load align(8) %0 : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void>
+ cir.indirect_goto %3 : !cir.ptr<!void>
+^bb1:
+ cir.label "a"
+ cir.return
+^bb2:
+ cir.label "b"
+ cir.return
+}
+
+// Attribute-carried labels precede cir.block_address labels: the constant's
+// "b" sorts before the block_address op's "a" in the successor list.
+// CHECK: cir.func @e()
+// CHECK: ^[[ABB:bb[0-9]+]]:
+// CHECK: cir.label "a"
+// CHECK: ^[[BBB:bb[0-9]+]]:
+// CHECK: cir.label "b"
+// CHECK: ^[[EIGB:bb[0-9]+]](%{{.*}}: !cir.ptr<!void>{{.*}}):
+// CHECK: cir.indirect_br {{.*}} : !cir.ptr<!void>, [
+// CHECK: ^[[BBB]]
+// CHECK: ^[[ABB]]
+// CHECK: ]
+
+cir.global internal @f.s = #cir.const_record<{#cir.block_addr_diff<@f, "b", "c"> : !s64i, #cir.block_addr_info<@f, "a"> : !cir.ptr<!void>}> : !rec_S
+
+cir.func @f() {
+ %0 = cir.alloca "ptr" align(8) init : !cir.ptr<!cir.ptr<!void>>
+ %1 = cir.load align(8) %0 : !cir.ptr<!cir.ptr<!void>>, !cir.ptr<!void>
----------------
andykaylor wrote:
Is this meant as a reference to `@f.s`? I expected to see it accessed via `get_global`.
https://github.com/llvm/llvm-project/pull/232870
More information about the cfe-commits
mailing list