diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index 9506439035b3..9e53db259bd8 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -518,7 +518,8 @@ void CIRGenModule::replaceGlobal(mlir::cir::GlobalOp Old, if (OldSymUses.has_value()) { for (auto Use : *OldSymUses) { auto UseOp = dyn_cast(Use.getUser()); - assert(UseOp && "GlobalOp symbol user is not a GetGlobalOp"); + if (!UseOp) + continue; auto UseOpResultValue = UseOp.getAddr(); UseOpResultValue.setType( diff --git a/clang/test/CIR/CodeGen/array-unknown-bound.cpp b/clang/test/CIR/CodeGen/array-unknown-bound.cpp index 27d06bed10c1..09f75ca27f27 100644 --- a/clang/test/CIR/CodeGen/array-unknown-bound.cpp +++ b/clang/test/CIR/CodeGen/array-unknown-bound.cpp @@ -3,9 +3,12 @@ extern int table[]; // CHECK: cir.global external @table = #cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array +int *table_ptr = table; +// CHECK: cir.global external @table_ptr = #cir.global_view<@table> : !cir.ptr + int test() { return table[1]; } // CHECK: cir.func @_Z4testv() -> !s32i extra( {inline = #cir.inline, optnone = #cir.optnone} ) { // CHECK-NEXT: %0 = cir.alloca !s32i, cir.ptr , ["__retval"] {alignment = 4 : i64} // CHECK-NEXT: %1 = cir.get_global @table : cir.ptr > -int table[3] {1, 2, 3}; \ No newline at end of file +int table[3] {1, 2, 3};