diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 68ee2b2c9773..47318bafcd8c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -53,16 +53,26 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy { llvm::RoundingMode DefaultConstrainedRounding = llvm::RoundingMode::Dynamic; llvm::StringMap GlobalsVersioning; - llvm::StringSet<> anonRecordNames; + llvm::StringMap RecordNames; public: CIRGenBuilderTy(mlir::MLIRContext &C, const CIRGenTypeCache &tc) - : CIRBaseBuilderTy(C), typeCache(tc) {} + : CIRBaseBuilderTy(C), typeCache(tc) { + RecordNames["anon"] = 0; // in order to start from the name "anon.0" + } std::string getUniqueAnonRecordName() { - std::string name = "anon." + std::to_string(anonRecordNames.size()); - anonRecordNames.insert(name); - return name; + return getUniqueRecordName("anon"); + } + + std::string getUniqueRecordName(const std::string& baseName) { + auto it = RecordNames.find(baseName); + if (it == RecordNames.end()) { + RecordNames[baseName] = 0; + return baseName; + } + + return baseName + "." + std::to_string(RecordNames[baseName]++); } // diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp index 002197ba5b3b..e9a491751752 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp @@ -91,7 +91,7 @@ std::string CIRGenTypes::getRecordTypeName(const clang::RecordDecl *recordDecl, if (!suffix.empty()) outStream << suffix; - return std::string(typeName); + return Builder.getUniqueRecordName(std::string(typeName)); } /// Return true if the specified type is already completely laid out. diff --git a/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp b/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp index 3479b7b7d56c..7932bb8891db 100644 --- a/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp +++ b/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp @@ -689,8 +689,8 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *D, // Fill in the struct *after* computing the base type. Filling in the body // signifies that the type is no longer opaque and record layout is complete, // but we may need to recursively layout D while laying D out as a base type. - *Ty = Builder.getCompleteStructTy( - builder.fieldTypes, getRecordTypeName(D, ""), builder.isPacked, D); + auto astAttr = mlir::cir::ASTRecordDeclAttr::get(Ty->getContext(), D); + Ty->complete(builder.fieldTypes, builder.isPacked, astAttr); auto RL = std::make_unique( Ty ? *Ty : mlir::cir::StructType{}, diff --git a/clang/test/CIR/CodeGen/bitfields.c b/clang/test/CIR/CodeGen/bitfields.c index f825640a6010..2671523cc4ca 100644 --- a/clang/test/CIR/CodeGen/bitfields.c +++ b/clang/test/CIR/CodeGen/bitfields.c @@ -55,13 +55,13 @@ typedef struct { // CHECK: !ty_D = !cir.struct // CHECK: !ty_T = !cir.struct -// CHECK: !ty_anon2E1_ = !cir.struct +// CHECK: !ty_anon2E0_ = !cir.struct // CHECK: !ty_anon_struct = !cir.struct // CHECK: #bfi_a = #cir.bitfield_info // CHECK: #bfi_e = #cir.bitfield_info // CHECK: !ty_S = !cir.struct, !u16i, !u32i}> // CHECK: !ty_U = !cir.struct}> -// CHECK: !ty___long = !cir.struct}> +// CHECK: !ty___long = !cir.struct}> // CHECK: #bfi_d = #cir.bitfield_info, size = 2, offset = 17, is_signed = true> // CHECK: cir.func {{.*@store_field}} diff --git a/clang/test/CIR/CodeGen/bitfields.cpp b/clang/test/CIR/CodeGen/bitfields.cpp index b5e9ed24d396..bdef100edf06 100644 --- a/clang/test/CIR/CodeGen/bitfields.cpp +++ b/clang/test/CIR/CodeGen/bitfields.cpp @@ -28,9 +28,9 @@ typedef struct { unsigned b; } T; // CHECK: !ty_T = !cir.struct -// CHECK: !ty_anon2E1_ = !cir.struct +// CHECK: !ty_anon2E0_ = !cir.struct // CHECK: !ty_S = !cir.struct, !u16i, !u32i}> -// CHECK: !ty___long = !cir.struct}> +// CHECK: !ty___long = !cir.struct}> // CHECK: cir.func @_Z11store_field // CHECK: [[TMP0:%.*]] = cir.alloca !ty_S, !cir.ptr diff --git a/clang/test/CIR/CodeGen/compound-literal.c b/clang/test/CIR/CodeGen/compound-literal.c index 74669589d084..bbd7fa4a4e75 100644 --- a/clang/test/CIR/CodeGen/compound-literal.c +++ b/clang/test/CIR/CodeGen/compound-literal.c @@ -37,8 +37,8 @@ int foo() { // CIR: cir.func no_proto @foo() -> !s32i // CIR: [[RET_MEM:%.*]] = cir.alloca !s32i, !cir.ptr, ["__retval"] {alignment = 4 : i64} -// CIR: [[COMPLITERAL_MEM:%.*]] = cir.alloca !ty_anon2E1_, !cir.ptr, [".compoundliteral"] {alignment = 4 : i64} -// CIR: [[FIELD:%.*]] = cir.get_member [[COMPLITERAL_MEM]][0] {name = "i"} : !cir.ptr -> !cir.ptr +// CIR: [[COMPLITERAL_MEM:%.*]] = cir.alloca !ty_anon2E0_, !cir.ptr, [".compoundliteral"] {alignment = 4 : i64} +// CIR: [[FIELD:%.*]] = cir.get_member [[COMPLITERAL_MEM]][0] {name = "i"} : !cir.ptr -> !cir.ptr // CIR: [[ONE:%.*]] = cir.const #cir.int<1> : !s32i // CIR: cir.store [[ONE]], [[FIELD]] : !s32i, !cir.ptr // CIR: [[ONE:%.*]] = cir.const #cir.int<1> : !s32i diff --git a/clang/test/CIR/CodeGen/coro-task.cpp b/clang/test/CIR/CodeGen/coro-task.cpp index d61c626ee763..bcc2f5fcc38b 100644 --- a/clang/test/CIR/CodeGen/coro-task.cpp +++ b/clang/test/CIR/CodeGen/coro-task.cpp @@ -356,10 +356,10 @@ folly::coro::Task go4() { // CHECK: } // CHECK: %12 = cir.scope { -// CHECK: %17 = cir.alloca !ty_anon2E5_, !cir.ptr, ["ref.tmp1"] {alignment = 1 : i64} +// CHECK: %17 = cir.alloca !ty_anon2E2_, !cir.ptr, ["ref.tmp1"] {alignment = 1 : i64} // Get the lambda invoker ptr via `lambda operator folly::coro::Task (*)(int const&)()` -// CHECK: %18 = cir.call @_ZZ3go4vENK3$_0cvPFN5folly4coro4TaskIiEERKiEEv(%17) : (!cir.ptr) -> !cir.ptr)>> +// CHECK: %18 = cir.call @_ZZ3go4vENK3$_0cvPFN5folly4coro4TaskIiEERKiEEv(%17) : (!cir.ptr) -> !cir.ptr)>> // CHECK: %19 = cir.unary(plus, %18) : !cir.ptr)>>, !cir.ptr)>> // CHECK: cir.yield %19 : !cir.ptr)>> // CHECK: } diff --git a/clang/test/CIR/CodeGen/forward-decls.cpp b/clang/test/CIR/CodeGen/forward-decls.cpp index 86e374626a20..3f004c952d4c 100644 --- a/clang/test/CIR/CodeGen/forward-decls.cpp +++ b/clang/test/CIR/CodeGen/forward-decls.cpp @@ -96,13 +96,12 @@ void testIndirectSelfReference(struct StructNodeA arg) { // RUN: FileCheck --check-prefix=CHECK5 --input-file=%t/complex_struct.cir %s // A sizeable complex struct just to double check that stuff is working. - -// CHECK5: !cir.struct, !cir.struct>, !cir.struct>, !cir.ptr>, !cir.ptr>} #cir.record.decl.ast>, !cir.struct>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !cir.struct, !cir.struct>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>, !cir.struct, !cir.struct} #cir.record.decl.ast>>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !ty_C, !cir.struct} #cir.record.decl.ast>>, !cir.struct} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !ty_C, !cir.struct} #cir.record.decl.ast>} #cir.record.decl.ast>>, !ty_anon2E4_} #cir.record.decl.ast> -// CHECK5: !cir.struct>, !ty_C, !ty_anon2E5_} #cir.record.decl.ast> -// CHECK5: !cir.struct +// CHECK5: !cir.struct, !cir.struct>, !cir.struct>, !cir.ptr>, !cir.ptr>} #cir.record.decl.ast>, !cir.struct>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> +// CHECK5: !cir.struct>, !cir.struct, !cir.struct>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>, !cir.struct, !cir.struct} #cir.record.decl.ast>>, !cir.struct>} #cir.record.decl.ast>} #cir.record.decl.ast>} #cir.record.decl.ast>>, !cir.ptr>} #cir.record.decl.ast> +// CHECK5: !cir.struct>, !ty_C, !cir.struct} #cir.record.decl.ast>>, !cir.struct} #cir.record.decl.ast>} #cir.record.decl.ast>>} #cir.record.decl.ast> +// CHECK5: !cir.struct>, !ty_C, !cir.struct} #cir.record.decl.ast>} #cir.record.decl.ast>>, !ty_anon2E2_} #cir.record.decl.ast> +// CHECK5: !cir.struct>, !ty_C, !ty_anon2E1_} #cir.record.decl.ast> +// CHECK5: !cir.struct struct A { struct { struct A *a1; diff --git a/clang/test/CIR/CodeGen/globals.c b/clang/test/CIR/CodeGen/globals.c index d73e136e2f0f..48a4db18bb63 100644 --- a/clang/test/CIR/CodeGen/globals.c +++ b/clang/test/CIR/CodeGen/globals.c @@ -57,25 +57,25 @@ const int i = 12; int i2 = i; struct { int i; } i3 = {i}; // CHECK: cir.global external @i2 = #cir.int<12> : !s32i -// CHECK: cir.global external @i3 = #cir.const_struct<{#cir.int<12> : !s32i}> : !ty_anon2E7_ +// CHECK: cir.global external @i3 = #cir.const_struct<{#cir.int<12> : !s32i}> : !ty_anon2E3_ int a[10][10][10]; int *a2 = &a[3][0][8]; struct { int *p; } a3 = {&a[3][0][8]}; // CHECK: cir.global external @a2 = #cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr -// CHECK: cir.global external @a3 = #cir.const_struct<{#cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr}> : !ty_anon2E9_ +// CHECK: cir.global external @a3 = #cir.const_struct<{#cir.global_view<@a, [3 : i32, 0 : i32, 8 : i32]> : !cir.ptr}> : !ty_anon2E4_ int p[10]; int *p1 = &p[0]; struct { int *x; } p2 = {&p[0]}; // CHECK: cir.global external @p1 = #cir.global_view<@p> : !cir.ptr -// CHECK: cir.global external @p2 = #cir.const_struct<{#cir.global_view<@p> : !cir.ptr}> : !ty_anon2E11_ +// CHECK: cir.global external @p2 = #cir.const_struct<{#cir.global_view<@p> : !cir.ptr}> : !ty_anon2E5_ int q[10]; int *q1 = q; struct { int *x; } q2 = {q}; // CHECK: cir.global external @q1 = #cir.global_view<@q> : !cir.ptr -// CHECK: cir.global external @q2 = #cir.const_struct<{#cir.global_view<@q> : !cir.ptr}> : !ty_anon2E13_ +// CHECK: cir.global external @q2 = #cir.const_struct<{#cir.global_view<@q> : !cir.ptr}> : !ty_anon2E6_ int foo() { extern int optind; diff --git a/clang/test/CIR/CodeGen/lambda.cpp b/clang/test/CIR/CodeGen/lambda.cpp index 84b38d567e09..b1084ff81bd3 100644 --- a/clang/test/CIR/CodeGen/lambda.cpp +++ b/clang/test/CIR/CodeGen/lambda.cpp @@ -6,13 +6,13 @@ void fn() { a(); } -// CHECK: !ty_anon2E2_ = !cir.struct +// CHECK: !ty_anon2E0_ = !cir.struct // CHECK-DAG: module // CHECK: cir.func lambda internal private @_ZZ2fnvENK3$_0clEv{{.*}}) extra // CHECK: cir.func @_Z2fnv() -// CHECK-NEXT: %0 = cir.alloca !ty_anon2E2_, !cir.ptr, ["a"] +// CHECK-NEXT: %0 = cir.alloca !ty_anon2E0_, !cir.ptr, ["a"] // CHECK: cir.call @_ZZ2fnvENK3$_0clEv void l0() { @@ -23,15 +23,15 @@ void l0() { // CHECK: cir.func lambda internal private @_ZZ2l0vENK3$_0clEv({{.*}}) extra -// CHECK: %0 = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] {alignment = 8 : i64} -// CHECK: cir.store %arg0, %0 : !cir.ptr, !cir.ptr> -// CHECK: %1 = cir.load %0 : !cir.ptr>, !cir.ptr -// CHECK: %2 = cir.get_member %1[0] {name = "i"} : !cir.ptr -> !cir.ptr> +// CHECK: %0 = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] {alignment = 8 : i64} +// CHECK: cir.store %arg0, %0 : !cir.ptr, !cir.ptr> +// CHECK: %1 = cir.load %0 : !cir.ptr>, !cir.ptr +// CHECK: %2 = cir.get_member %1[0] {name = "i"} : !cir.ptr -> !cir.ptr> // CHECK: %3 = cir.load %2 : !cir.ptr>, !cir.ptr // CHECK: %4 = cir.load %3 : !cir.ptr, !s32i // CHECK: %5 = cir.const #cir.int<1> : !s32i // CHECK: %6 = cir.binop(add, %4, %5) nsw : !s32i -// CHECK: %7 = cir.get_member %1[0] {name = "i"} : !cir.ptr -> !cir.ptr> +// CHECK: %7 = cir.get_member %1[0] {name = "i"} : !cir.ptr -> !cir.ptr> // CHECK: %8 = cir.load %7 : !cir.ptr>, !cir.ptr // CHECK: cir.store %6, %8 : !s32i, !cir.ptr @@ -45,15 +45,15 @@ auto g() { }; } -// CHECK: cir.func @_Z1gv() -> !ty_anon2E6_ -// CHECK: %0 = cir.alloca !ty_anon2E6_, !cir.ptr, ["__retval"] {alignment = 8 : i64} +// CHECK: cir.func @_Z1gv() -> !ty_anon2E3_ +// CHECK: %0 = cir.alloca !ty_anon2E3_, !cir.ptr, ["__retval"] {alignment = 8 : i64} // CHECK: %1 = cir.alloca !s32i, !cir.ptr, ["i", init] {alignment = 4 : i64} // CHECK: %2 = cir.const #cir.int<12> : !s32i // CHECK: cir.store %2, %1 : !s32i, !cir.ptr -// CHECK: %3 = cir.get_member %0[0] {name = "i"} : !cir.ptr -> !cir.ptr> +// CHECK: %3 = cir.get_member %0[0] {name = "i"} : !cir.ptr -> !cir.ptr> // CHECK: cir.store %1, %3 : !cir.ptr, !cir.ptr> -// CHECK: %4 = cir.load %0 : !cir.ptr, !ty_anon2E6_ -// CHECK: cir.return %4 : !ty_anon2E6_ +// CHECK: %4 = cir.load %0 : !cir.ptr, !ty_anon2E3_ +// CHECK: cir.return %4 : !ty_anon2E3_ auto g2() { int i = 12; @@ -65,15 +65,15 @@ auto g2() { } // Should be same as above because of NRVO -// CHECK: cir.func @_Z2g2v() -> !ty_anon2E8_ -// CHECK-NEXT: %0 = cir.alloca !ty_anon2E8_, !cir.ptr, ["__retval", init] {alignment = 8 : i64} +// CHECK: cir.func @_Z2g2v() -> !ty_anon2E4_ +// CHECK-NEXT: %0 = cir.alloca !ty_anon2E4_, !cir.ptr, ["__retval", init] {alignment = 8 : i64} // CHECK-NEXT: %1 = cir.alloca !s32i, !cir.ptr, ["i", init] {alignment = 4 : i64} // CHECK-NEXT: %2 = cir.const #cir.int<12> : !s32i // CHECK-NEXT: cir.store %2, %1 : !s32i, !cir.ptr -// CHECK-NEXT: %3 = cir.get_member %0[0] {name = "i"} : !cir.ptr -> !cir.ptr> +// CHECK-NEXT: %3 = cir.get_member %0[0] {name = "i"} : !cir.ptr -> !cir.ptr> // CHECK-NEXT: cir.store %1, %3 : !cir.ptr, !cir.ptr> -// CHECK-NEXT: %4 = cir.load %0 : !cir.ptr, !ty_anon2E8_ -// CHECK-NEXT: cir.return %4 : !ty_anon2E8_ +// CHECK-NEXT: %4 = cir.load %0 : !cir.ptr, !ty_anon2E4_ +// CHECK-NEXT: cir.return %4 : !ty_anon2E4_ int f() { return g2()(); @@ -82,10 +82,10 @@ int f() { // CHECK: cir.func @_Z1fv() -> !s32i // CHECK-NEXT: %0 = cir.alloca !s32i, !cir.ptr, ["__retval"] {alignment = 4 : i64} // CHECK-NEXT: cir.scope { -// CHECK-NEXT: %2 = cir.alloca !ty_anon2E8_, !cir.ptr, ["ref.tmp0"] {alignment = 8 : i64} -// CHECK-NEXT: %3 = cir.call @_Z2g2v() : () -> !ty_anon2E8_ -// CHECK-NEXT: cir.store %3, %2 : !ty_anon2E8_, !cir.ptr -// CHECK-NEXT: %4 = cir.call @_ZZ2g2vENK3$_0clEv(%2) : (!cir.ptr) -> !s32i +// CHECK-NEXT: %2 = cir.alloca !ty_anon2E4_, !cir.ptr, ["ref.tmp0"] {alignment = 8 : i64} +// CHECK-NEXT: %3 = cir.call @_Z2g2v() : () -> !ty_anon2E4_ +// CHECK-NEXT: cir.store %3, %2 : !ty_anon2E4_, !cir.ptr +// CHECK-NEXT: %4 = cir.call @_ZZ2g2vENK3$_0clEv(%2) : (!cir.ptr) -> !s32i // CHECK-NEXT: cir.store %4, %0 : !s32i, !cir.ptr // CHECK-NEXT: } // CHECK-NEXT: %1 = cir.load %0 : !cir.ptr, !s32i @@ -114,8 +114,8 @@ int g3() { // 1. Use `operator int (*)(int const&)()` to retrieve the fnptr to `__invoke()`. // CHECK: %3 = cir.scope { -// CHECK: %7 = cir.alloca !ty_anon2E11_, !cir.ptr, ["ref.tmp0"] {alignment = 1 : i64} -// CHECK: %8 = cir.call @_ZZ2g3vENK3$_0cvPFiRKiEEv(%7) : (!cir.ptr) -> !cir.ptr)>> +// CHECK: %7 = cir.alloca !ty_anon2E5_, !cir.ptr, ["ref.tmp0"] {alignment = 1 : i64} +// CHECK: %8 = cir.call @_ZZ2g3vENK3$_0cvPFiRKiEEv(%7) : (!cir.ptr) -> !cir.ptr)>> // CHECK: %9 = cir.unary(plus, %8) : !cir.ptr)>>, !cir.ptr)>> // CHECK: cir.yield %9 : !cir.ptr)>> // CHECK: } diff --git a/clang/test/CIR/CodeGen/string-literals.c b/clang/test/CIR/CodeGen/string-literals.c index 23728b4f4c4c..7be9d6819d3e 100644 --- a/clang/test/CIR/CodeGen/string-literals.c +++ b/clang/test/CIR/CodeGen/string-literals.c @@ -17,7 +17,7 @@ struct { // CIR: }> // LLVM-LABEL: @literals -// LLVM: global %struct.anon.1 { +// LLVM: global %struct.anon.0 { // LLVM: [10 x i8] c"1\00\00\00\00\00\00\00\00\00", // LLVM: [10 x i8] zeroinitializer, // LLVM: [10 x i8] zeroinitializer diff --git a/clang/test/CIR/CodeGen/struct.c b/clang/test/CIR/CodeGen/struct.c index f473a08fa8ac..43f1576bb09a 100644 --- a/clang/test/CIR/CodeGen/struct.c +++ b/clang/test/CIR/CodeGen/struct.c @@ -25,6 +25,8 @@ void baz(void) { // CHECK-DAG: !ty_Node = !cir.struct>} #cir.record.decl.ast> // CHECK-DAG: !ty_Bar = !cir.struct // CHECK-DAG: !ty_Foo = !cir.struct +// CHECK-DAG: !ty_SLocal = !cir.struct +// CHECK-DAG: !ty_SLocal2E0_ = !cir.struct // CHECK-DAG: module {{.*}} { // CHECK: cir.func @baz() // CHECK-NEXT: %0 = cir.alloca !ty_Bar, !cir.ptr, ["b"] {alignment = 4 : i64} @@ -99,3 +101,15 @@ void local_decl(void) { void useRecursiveType(NodeStru* a) { a->next = 0; } + +// CHECK-DAG: cir.alloca !ty_SLocal, !cir.ptr, ["loc", init] {alignment = 4 : i64} +// CHECK-DAG: cir.scope { +// CHECK-DAG: cir.alloca !ty_SLocal2E0_, !cir.ptr, ["loc", init] {alignment = 4 : i64} +void local_structs(int a, float b) { + struct SLocal { int x; }; + struct SLocal loc = {a}; + { + struct SLocal { float y; }; + struct SLocal loc = {b}; + } +} diff --git a/clang/test/CIR/CodeGen/union-init.c b/clang/test/CIR/CodeGen/union-init.c index 1147cf52cfb5..8838b67ff283 100644 --- a/clang/test/CIR/CodeGen/union-init.c +++ b/clang/test/CIR/CodeGen/union-init.c @@ -22,11 +22,11 @@ void foo(int x) { // CHECK: %[[VAL_1:.*]] = cir.alloca !s32i, !cir.ptr, ["x", init] {alignment = 4 : i64} // CHECK: %[[VAL_2:.*]] = cir.alloca !ty_A, !cir.ptr, ["a", init] {alignment = 4 : i64} // CHECK: cir.store {{.*}}, %[[VAL_1]] : !s32i, !cir.ptr -// CHECK: %[[VAL_3:.*]] = cir.get_member %[[VAL_2]][1] {name = ""} : !cir.ptr -> !cir.ptr -// CHECK: %[[VAL_4:.*]] = cir.cast(bitcast, %[[VAL_3]] : !cir.ptr), !cir.ptr +// CHECK: %[[VAL_3:.*]] = cir.get_member %[[VAL_2]][1] {name = ""} : !cir.ptr -> !cir.ptr +// CHECK: %[[VAL_4:.*]] = cir.cast(bitcast, %[[VAL_3]] : !cir.ptr), !cir.ptr // CHECK: %[[VAL_5:.*]] = cir.load %[[VAL_1]] : !cir.ptr, !s32i // CHECK: %[[VAL_6:.*]] = cir.set_bitfield(#[[bfi_x]], %[[VAL_4]] : !cir.ptr, %[[VAL_5]] : !s32i) -> !s32i -// CHECK: %[[VAL_7:.*]] = cir.cast(bitcast, %[[VAL_3]] : !cir.ptr), !cir.ptr +// CHECK: %[[VAL_7:.*]] = cir.cast(bitcast, %[[VAL_3]] : !cir.ptr), !cir.ptr // CHECK: %[[VAL_8:.*]] = cir.const #cir.int<0> : !s32i // CHECK: %[[VAL_9:.*]] = cir.set_bitfield(#[[bfi_y]], %[[VAL_7]] : !cir.ptr, %[[VAL_8]] : !s32i) -> !s32i // CHECK: cir.return diff --git a/clang/test/CIR/CodeGen/union.cpp b/clang/test/CIR/CodeGen/union.cpp index 7ccb520be2c2..9c8a2002eeb1 100644 --- a/clang/test/CIR/CodeGen/union.cpp +++ b/clang/test/CIR/CodeGen/union.cpp @@ -7,14 +7,14 @@ typedef union { yolo y; struct { int *lifecnt; int genpad; }; } yolm2; typedef union { yolo y; struct { bool life; int genpad; }; } yolm3; // CHECK-DAG: !ty_U23A3ADummy = !cir.struct -// CHECK-DAG: !ty_anon2E5_ = !cir.struct -// CHECK-DAG: !ty_anon2E1_ = !cir.struct +// CHECK-DAG: !ty_anon2E0_ = !cir.struct +// CHECK-DAG: !ty_anon2E2_ = !cir.struct // CHECK-DAG: !ty_yolo = !cir.struct -// CHECK-DAG: !ty_anon2E3_ = !cir.struct, !s32i} #cir.record.decl.ast> +// CHECK-DAG: !ty_anon2E1_ = !cir.struct, !s32i} #cir.record.decl.ast> -// CHECK-DAG: !ty_yolm = !cir.struct -// CHECK-DAG: !ty_yolm3_ = !cir.struct -// CHECK-DAG: !ty_yolm2_ = !cir.struct +// CHECK-DAG: !ty_yolm = !cir.struct +// CHECK-DAG: !ty_yolm3_ = !cir.struct +// CHECK-DAG: !ty_yolm2_ = !cir.struct // Should generate a union type with all members preserved. union U {