Skip to content

Commit 2414a7c

Browse files
gitoleglanza
authored andcommitted
[CIR][CodeGen][BugFix] Fixes structures name collisions (llvm#844)
CIR Codegen fails to generate functions with local types with the same names. For instance, the next code : ``` void foo(int a, float b) { struct A { int x; }; struct A loc = {a}; { struct A { float y; }; struct A loc = {b}; } } ``` fails with on the next assertion: `Unable to find record layout information for type`. The problem is that we don't create record layout for the structures with equal names and `CIRGenTypes::convertRecordDeclType` returns the wrong type for the second struct type in the example above. This PR fixes this problem. In the original codegen the call to `Ty->setName(name)` resolves name collisions and assign a proper name for the type. In our case looks like we need to use the same approach as we did for the anonymous structures, i.e. to track the used names in the builder. Also, I fixed the struct type creation. Previously, the type was created several times - first in the `CIRGenTypes::convertRecordDeclType` and then in the `CIRGenTypes::computeRecordLayout`. This is why the indexes used by the anonymous structures naming had relatively big values and this is where the most changes on the tests come from.
1 parent 7a9fb5a commit 2414a7c

File tree

14 files changed

+83
-60
lines changed

14 files changed

+83
-60
lines changed

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,26 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
5353
llvm::RoundingMode DefaultConstrainedRounding = llvm::RoundingMode::Dynamic;
5454

5555
llvm::StringMap<unsigned> GlobalsVersioning;
56-
llvm::StringSet<> anonRecordNames;
56+
llvm::StringMap<unsigned> RecordNames;
5757

5858
public:
5959
CIRGenBuilderTy(mlir::MLIRContext &C, const CIRGenTypeCache &tc)
60-
: CIRBaseBuilderTy(C), typeCache(tc) {}
60+
: CIRBaseBuilderTy(C), typeCache(tc) {
61+
RecordNames["anon"] = 0; // in order to start from the name "anon.0"
62+
}
6163

6264
std::string getUniqueAnonRecordName() {
63-
std::string name = "anon." + std::to_string(anonRecordNames.size());
64-
anonRecordNames.insert(name);
65-
return name;
65+
return getUniqueRecordName("anon");
66+
}
67+
68+
std::string getUniqueRecordName(const std::string& baseName) {
69+
auto it = RecordNames.find(baseName);
70+
if (it == RecordNames.end()) {
71+
RecordNames[baseName] = 0;
72+
return baseName;
73+
}
74+
75+
return baseName + "." + std::to_string(RecordNames[baseName]++);
6676
}
6777

6878
//

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ std::string CIRGenTypes::getRecordTypeName(const clang::RecordDecl *recordDecl,
9191
if (!suffix.empty())
9292
outStream << suffix;
9393

94-
return std::string(typeName);
94+
return Builder.getUniqueRecordName(std::string(typeName));
9595
}
9696

9797
/// Return true if the specified type is already completely laid out.

clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,8 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D,
689689
// Fill in the struct *after* computing the base type. Filling in the body
690690
// signifies that the type is no longer opaque and record layout is complete,
691691
// but we may need to recursively layout D while laying D out as a base type.
692-
*Ty = Builder.getCompleteStructTy(
693-
builder.fieldTypes, getRecordTypeName(D, ""), builder.isPacked, D);
692+
auto astAttr = mlir::cir::ASTRecordDeclAttr::get(Ty->getContext(), D);
693+
Ty->complete(builder.fieldTypes, builder.isPacked, astAttr);
694694

695695
auto RL = std::make_unique<CIRGenRecordLayout>(
696696
Ty ? *Ty : mlir::cir::StructType{},

clang/test/CIR/CodeGen/bitfields.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ typedef struct {
5555

5656
// CHECK: !ty_D = !cir.struct<struct "D" {!cir.int<u, 16>, !cir.int<s, 32>}>
5757
// CHECK: !ty_T = !cir.struct<struct "T" {!cir.int<u, 8>, !cir.int<u, 32>} #cir.record.decl.ast>
58-
// CHECK: !ty_anon2E1_ = !cir.struct<struct "anon.1" {!cir.int<u, 32>} #cir.record.decl.ast>
58+
// CHECK: !ty_anon2E0_ = !cir.struct<struct "anon.0" {!cir.int<u, 32>} #cir.record.decl.ast>
5959
// CHECK: !ty_anon_struct = !cir.struct<struct {!cir.int<u, 8>, !cir.int<u, 8>, !cir.int<s, 32>}>
6060
// CHECK: #bfi_a = #cir.bitfield_info<name = "a", storage_type = !u8i, size = 3, offset = 0, is_signed = true>
6161
// CHECK: #bfi_e = #cir.bitfield_info<name = "e", storage_type = !u16i, size = 15, offset = 0, is_signed = true>
6262
// CHECK: !ty_S = !cir.struct<struct "S" {!cir.int<u, 32>, !cir.array<!cir.int<u, 8> x 3>, !cir.int<u, 16>, !cir.int<u, 32>}>
6363
// CHECK: !ty_U = !cir.struct<struct "U" {!cir.int<s, 8>, !cir.int<s, 8>, !cir.int<s, 8>, !cir.array<!cir.int<u, 8> x 9>}>
64-
// CHECK: !ty___long = !cir.struct<struct "__long" {!cir.struct<struct "anon.1" {!cir.int<u, 32>} #cir.record.decl.ast>, !cir.int<u, 32>, !cir.ptr<!cir.int<u, 32>>}>
64+
// CHECK: !ty___long = !cir.struct<struct "__long" {!cir.struct<struct "anon.0" {!cir.int<u, 32>} #cir.record.decl.ast>, !cir.int<u, 32>, !cir.ptr<!cir.int<u, 32>>}>
6565
// CHECK: #bfi_d = #cir.bitfield_info<name = "d", storage_type = !cir.array<!u8i x 3>, size = 2, offset = 17, is_signed = true>
6666

6767
// CHECK: cir.func {{.*@store_field}}

clang/test/CIR/CodeGen/bitfields.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ typedef struct {
2828
unsigned b;
2929
} T;
3030
// CHECK: !ty_T = !cir.struct<struct "T" {!cir.int<u, 8>, !cir.int<u, 32>} #cir.record.decl.ast>
31-
// CHECK: !ty_anon2E1_ = !cir.struct<struct "anon.1" {!cir.int<u, 32>} #cir.record.decl.ast>
31+
// CHECK: !ty_anon2E0_ = !cir.struct<struct "anon.0" {!cir.int<u, 32>} #cir.record.decl.ast>
3232
// CHECK: !ty_S = !cir.struct<struct "S" {!cir.int<u, 32>, !cir.array<!cir.int<u, 8> x 3>, !cir.int<u, 16>, !cir.int<u, 32>}>
33-
// CHECK: !ty___long = !cir.struct<struct "__long" {!cir.struct<struct "anon.1" {!cir.int<u, 32>} #cir.record.decl.ast>, !cir.int<u, 32>, !cir.ptr<!cir.int<u, 32>>}>
33+
// CHECK: !ty___long = !cir.struct<struct "__long" {!cir.struct<struct "anon.0" {!cir.int<u, 32>} #cir.record.decl.ast>, !cir.int<u, 32>, !cir.ptr<!cir.int<u, 32>>}>
3434

3535
// CHECK: cir.func @_Z11store_field
3636
// CHECK: [[TMP0:%.*]] = cir.alloca !ty_S, !cir.ptr<!ty_S>

clang/test/CIR/CodeGen/compound-literal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ int foo() {
3737

3838
// CIR: cir.func no_proto @foo() -> !s32i
3939
// CIR: [[RET_MEM:%.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] {alignment = 4 : i64}
40-
// CIR: [[COMPLITERAL_MEM:%.*]] = cir.alloca !ty_anon2E1_, !cir.ptr<!ty_anon2E1_>, [".compoundliteral"] {alignment = 4 : i64}
41-
// CIR: [[FIELD:%.*]] = cir.get_member [[COMPLITERAL_MEM]][0] {name = "i"} : !cir.ptr<!ty_anon2E1_> -> !cir.ptr<!s32i>
40+
// CIR: [[COMPLITERAL_MEM:%.*]] = cir.alloca !ty_anon2E0_, !cir.ptr<!ty_anon2E0_>, [".compoundliteral"] {alignment = 4 : i64}
41+
// CIR: [[FIELD:%.*]] = cir.get_member [[COMPLITERAL_MEM]][0] {name = "i"} : !cir.ptr<!ty_anon2E0_> -> !cir.ptr<!s32i>
4242
// CIR: [[ONE:%.*]] = cir.const #cir.int<1> : !s32i
4343
// CIR: cir.store [[ONE]], [[FIELD]] : !s32i, !cir.ptr<!s32i>
4444
// CIR: [[ONE:%.*]] = cir.const #cir.int<1> : !s32i

clang/test/CIR/CodeGen/coro-task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,10 @@ folly::coro::Task<int> go4() {
356356
// CHECK: }
357357

358358
// CHECK: %12 = cir.scope {
359-
// CHECK: %17 = cir.alloca !ty_anon2E5_, !cir.ptr<!ty_anon2E5_>, ["ref.tmp1"] {alignment = 1 : i64}
359+
// CHECK: %17 = cir.alloca !ty_anon2E2_, !cir.ptr<!ty_anon2E2_>, ["ref.tmp1"] {alignment = 1 : i64}
360360

361361
// Get the lambda invoker ptr via `lambda operator folly::coro::Task<int> (*)(int const&)()`
362-
// CHECK: %18 = cir.call @_ZZ3go4vENK3$_0cvPFN5folly4coro4TaskIiEERKiEEv(%17) : (!cir.ptr<!ty_anon2E5_>) -> !cir.ptr<!cir.func<![[IntTask]] (!cir.ptr<!s32i>)>>
362+
// CHECK: %18 = cir.call @_ZZ3go4vENK3$_0cvPFN5folly4coro4TaskIiEERKiEEv(%17) : (!cir.ptr<!ty_anon2E2_>) -> !cir.ptr<!cir.func<![[IntTask]] (!cir.ptr<!s32i>)>>
363363
// CHECK: %19 = cir.unary(plus, %18) : !cir.ptr<!cir.func<![[IntTask]] (!cir.ptr<!s32i>)>>, !cir.ptr<!cir.func<![[IntTask]] (!cir.ptr<!s32i>)>>
364364
// CHECK: cir.yield %19 : !cir.ptr<!cir.func<![[IntTask]] (!cir.ptr<!s32i>)>>
365365
// CHECK: }

clang/test/CIR/CodeGen/forward-decls.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,12 @@ void testIndirectSelfReference(struct StructNodeA arg) {
9696
// RUN: FileCheck --check-prefix=CHECK5 --input-file=%t/complex_struct.cir %s
9797

9898
// A sizeable complex struct just to double check that stuff is working.
99-
100-
// CHECK5: !cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1">, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A">>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.5" {!cir.ptr<!cir.struct<struct "A">>, !cir.struct<struct "anon.4" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast>
101-
// CHECK5: !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C">, !cir.struct<union "anon.5" {!cir.ptr<!cir.struct<struct "A">>, !cir.struct<struct "anon.4" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C">, !cir.struct<union "anon.5" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.struct<struct "anon.4" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>
102-
// CHECK5: !cir.struct<struct "anon.4" {!cir.ptr<!cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.5" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.struct<struct "anon.4">} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast>
103-
// CHECK5: !cir.struct<union "anon.5" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A">>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.5">} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.struct<struct "anon.4" {!cir.ptr<!cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.5">} #cir.record.decl.ast>>} #cir.record.decl.ast>} #cir.record.decl.ast>
104-
// CHECK5: !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.5" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.struct<struct "anon.4" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>
105-
// CHECK5: !cir.struct<struct "A" {!cir.struct<struct "anon.1" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A">>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.5" {!cir.ptr<!cir.struct<struct "A">>, !cir.struct<struct "anon.4" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>
99+
// CHECK5: !cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0">, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A">>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.1" {!cir.ptr<!cir.struct<struct "A">>, !cir.struct<struct "anon.2" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast>
100+
// CHECK5: !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C">, !cir.struct<union "anon.1" {!cir.ptr<!cir.struct<struct "A">>, !cir.struct<struct "anon.2" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C">, !cir.struct<union "anon.1" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.struct<struct "anon.2" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>
101+
// CHECK5: !cir.struct<struct "anon.2" {!cir.ptr<!cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.1" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.struct<struct "anon.2">} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast>
102+
// CHECK5: !cir.struct<union "anon.1" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A">>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.1">} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.struct<struct "anon.2" {!cir.ptr<!cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.1">} #cir.record.decl.ast>>} #cir.record.decl.ast>} #cir.record.decl.ast>
103+
// CHECK5: !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.1" {!cir.ptr<!cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B">} #cir.record.decl.ast>>, !cir.struct<struct "anon.2" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>
104+
// CHECK5: !cir.struct<struct "A" {!cir.struct<struct "anon.0" {!cir.ptr<!cir.struct<struct "A">>} #cir.record.decl.ast>, !cir.struct<struct "B" {!cir.ptr<!cir.struct<struct "B">>, !cir.struct<struct "C" {!cir.ptr<!cir.struct<struct "A">>, !cir.ptr<!cir.struct<struct "B">>, !cir.ptr<!cir.struct<struct "C">>} #cir.record.decl.ast>, !cir.struct<union "anon.1" {!cir.ptr<!cir.struct<struct "A">>, !cir.struct<struct "anon.2" {!cir.ptr<!cir.struct<struct "B">>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>
106105
struct A {
107106
struct {
108107
struct A *a1;

clang/test/CIR/CodeGen/globals.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,25 @@ const int i = 12;
5858
int i2 = i;
5959
struct { int i; } i3 = {i};
6060
// CHECK: cir.global external @i2 = #cir.int<12> : !s32i
61-
// CHECK: cir.global external @i3 = #cir.const_struct<{#cir.int<12> : !s32i}> : !ty_anon2E7_
61+
// CHECK: cir.global external @i3 = #cir.const_struct<{#cir.int<12> : !s32i}> : !ty_anon2E3_
6262

6363
int a[10][10][10];
6464
int *a2 = &a[3][0][8];
6565
struct { int *p; } a3 = {&a[3][0][8]};
6666
// CHECK: cir.global external @a2 = #cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr<!s32i>
67-
// CHECK: cir.global external @a3 = #cir.const_struct<{#cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr<!s32i>}> : !ty_anon2E9_
67+
// CHECK: cir.global external @a3 = #cir.const_struct<{#cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr<!s32i>}> : !ty_anon2E4_
6868

6969
int p[10];
7070
int *p1 = &p[0];
7171
struct { int *x; } p2 = {&p[0]};
7272
// CHECK: cir.global external @p1 = #cir.global_view<@p> : !cir.ptr<!s32i>
73-
// CHECK: cir.global external @p2 = #cir.const_struct<{#cir.global_view<@p> : !cir.ptr<!s32i>}> : !ty_anon2E11_
73+
// CHECK: cir.global external @p2 = #cir.const_struct<{#cir.global_view<@p> : !cir.ptr<!s32i>}> : !ty_anon2E5_
7474

7575
int q[10];
7676
int *q1 = q;
7777
struct { int *x; } q2 = {q};
7878
// CHECK: cir.global external @q1 = #cir.global_view<@q> : !cir.ptr<!s32i>
79-
// CHECK: cir.global external @q2 = #cir.const_struct<{#cir.global_view<@q> : !cir.ptr<!s32i>}> : !ty_anon2E13_
79+
// CHECK: cir.global external @q2 = #cir.const_struct<{#cir.global_view<@q> : !cir.ptr<!s32i>}> : !ty_anon2E6_
8080

8181
int foo() {
8282
extern int optind;

0 commit comments

Comments
 (0)