Skip to content

Commit

Permalink
remove the too restrictive assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
Lancern committed Jan 8, 2024
1 parent 0766623 commit 2bca2f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ void CIRGenModule::replaceGlobal(mlir::cir::GlobalOp Old,
if (OldSymUses.has_value()) {
for (auto Use : *OldSymUses) {
auto UseOp = dyn_cast<mlir::cir::GetGlobalOp>(Use.getUser());
assert(UseOp && "GlobalOp symbol user is not a GetGlobalOp");
if (!UseOp)
continue;

auto UseOpResultValue = UseOp.getAddr();
UseOpResultValue.setType(
Expand Down
5 changes: 4 additions & 1 deletion clang/test/CIR/CodeGen/array-unknown-bound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<!s32i x 3>

int *table_ptr = table;
// CHECK: cir.global external @table_ptr = #cir.global_view<@table> : !cir.ptr<!s32i>

int test() { return table[1]; }
// CHECK: cir.func @_Z4testv() -> !s32i extra( {inline = #cir.inline<no>, optnone = #cir.optnone} ) {
// CHECK-NEXT: %0 = cir.alloca !s32i, cir.ptr <!s32i>, ["__retval"] {alignment = 4 : i64}
// CHECK-NEXT: %1 = cir.get_global @table : cir.ptr <!cir.array<!s32i x 3>>

int table[3] {1, 2, 3};
int table[3] {1, 2, 3};

0 comments on commit 2bca2f4

Please sign in to comment.