[clang] [CIR] Keep CIR global types visible across lowering replacements (PR #238698)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 01:07:24 PST 2026
================
@@ -0,0 +1,26 @@
+// RUN: cir-opt %s --cir-to-llvm -o - | FileCheck %s
+
+!void = !cir.void
+!arr_ty = !cir.array<!cir.ptr<!void> x 100>
+!bulk_ty = !cir.array<!cir.ptr<!cir.array<!cir.ptr<!void> x 100>> x 2>
+
+module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
+ // Region-initialized, so its LLVM type is adjusted (grouped struct).
+ cir.global external dso_local @arr = #cir.const_array<[
+ #cir.global_view<@arr, [5 : i32]> : !cir.ptr<!void>,
+ #cir.global_view<@arr, [7 : i32]> : !cir.ptr<!void>
+ ], trailing_zeros> : !arr_ty
+
+ // Unindexed views of @arr: bulk lowering must see the CIR array type
+ // via the stash, not the adjusted LLVM struct type.
+ cir.global external dso_local @bulk = #cir.const_array<[
+ #cir.global_view<@arr> : !cir.ptr<!cir.array<!cir.ptr<!void> x 100>>,
+ #cir.global_view<@arr> : !cir.ptr<!cir.array<!cir.ptr<!void> x 100>>
+ ]> : !bulk_ty
+}
+
+// CHECK: llvm.mlir.global external @arr
+// CHECK: llvm.insertvalue
+// CHECK: llvm.mlir.global external @bulk([@arr, @arr])
+// CHECK-NOT: llvm.insertvalue
+// CHECK-NOT: llvm.return
----------------
xlauko wrote:
Nit: the second `CHECK-NOT` doesn't add anything.
https://github.com/llvm/llvm-project/pull/238698
More information about the cfe-commits
mailing list