diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td index 178d944f1df7..abbee1419613 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td @@ -110,12 +110,19 @@ def CIR_StructType : CIR_Type<"Struct", "struct", "mlir::StringAttr":$typeName, "bool":$body, "bool":$packed, + "mlir::cir::StructType::RecordKind":$kind, "std::optional<::mlir::cir::ASTRecordDeclAttr>":$ast ); let hasCustomAssemblyFormat = 1; let extraClassDeclaration = [{ + enum RecordKind : uint32_t { + Class, + Union, + Struct + }; + private: // All these support lazily computation and storage // for the struct size and alignment. @@ -127,6 +134,27 @@ def CIR_StructType : CIR_Type<"Struct", "struct", size_t getNumElements() const { return getMembers().size(); } bool isOpaque() const { return !getBody(); } bool isPadded(const ::mlir::DataLayout &dataLayout) const; + + std::string getPrefixedName() { + const auto name = getTypeName().getValue().str(); + switch (getKind()) { + case RecordKind::Class: + return "class." + name; + case RecordKind::Union: + return "union "+ name; + case RecordKind::Struct: + return "struct." + name; + } + } + + /// Return whether this is a class declaration. + bool isClass() const { return getKind() == RecordKind::Class; } + + /// Return whether this is a union declaration. + bool isUnion() const { return getKind() == RecordKind::Union; } + + /// Return whether this is a struct declaration. + bool isStruct() const { return getKind() == RecordKind::Struct; } }]; let extraClassDefinition = [{ diff --git a/clang/lib/CIR/CodeGen/CIRGenBuilder.h b/clang/lib/CIR/CodeGen/CIRGenBuilder.h index 58f19d4c87b8..439af3cf7582 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuilder.h +++ b/clang/lib/CIR/CodeGen/CIRGenBuilder.h @@ -13,6 +13,8 @@ #include "CIRGenTypeCache.h" #include "UnimplementedFeatureGuarding.h" +#include "clang/AST/Decl.h" +#include "clang/AST/Type.h" #include "clang/CIR/Dialect/IR/CIRAttrs.h" #include "clang/CIR/Dialect/IR/CIRDialect.h" #include "clang/CIR/Dialect/IR/CIROpsEnums.h" @@ -168,7 +170,7 @@ class CIRGenBuilderTy : public mlir::OpBuilder { if (!structTy) structTy = getType( members, mlir::StringAttr::get(getContext()), - /*body=*/true, packed, + /*body=*/true, packed, mlir::cir::StructType::Struct, /*ast=*/std::nullopt); // Return zero or anonymous constant struct. @@ -384,16 +386,36 @@ class CIRGenBuilderTy : public mlir::OpBuilder { return getStructTy(members, "", body, packed, ast); } + /// Get a CIR record kind from a AST declaration tag. + mlir::cir::StructType::RecordKind + getRecordKind(const clang::TagTypeKind kind) { + switch (kind) { + case clang::TagTypeKind::Struct: + return mlir::cir::StructType::Struct; + case clang::TagTypeKind::Union: + return mlir::cir::StructType::Union; + case clang::TagTypeKind::Class: + return mlir::cir::StructType::Class; + case clang::TagTypeKind::Interface: + llvm_unreachable("interface records are NYI"); + case clang::TagTypeKind::Enum: + llvm_unreachable("enum records are NYI"); + } + } + /// Get a CIR named struct type. mlir::cir::StructType getStructTy(llvm::ArrayRef members, llvm::StringRef name, bool body, bool packed, const clang::RecordDecl *ast) { const auto nameAttr = getStringAttr(name); std::optional astAttr = std::nullopt; - if (ast) + auto kind = mlir::cir::StructType::RecordKind::Struct; + if (ast) { astAttr = getAttr(ast); + kind = getRecordKind(ast->getTagKind()); + } return mlir::cir::StructType::get(getContext(), members, nameAttr, body, - packed, astAttr); + packed, kind, astAttr); } // diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp index 5f5f928cbfe2..90df6588e25c 100644 --- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp @@ -46,8 +46,6 @@ std::string CIRGenTypes::getRecordTypeName(const clang::RecordDecl *recordDecl, llvm::SmallString<256> typeName; llvm::raw_svector_ostream outStream(typeName); - outStream << recordDecl->getKindName() << '.'; - PrintingPolicy policy = recordDecl->getASTContext().getPrintingPolicy(); policy.SuppressInlineNamespace = false; @@ -169,8 +167,7 @@ mlir::Type CIRGenTypes::convertRecordDeclType(const clang::RecordDecl *RD) { // Handle forward decl / incomplete types. if (!entry) { auto name = getRecordTypeName(RD, ""); - entry = Builder.getStructTy({}, name, /*body=*/false, - /*packed=*/false, RD); + entry = Builder.getStructTy({}, name, /*body=*/false, /*packed=*/false, RD); recordDeclTypes[key] = entry; } diff --git a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp index 706e51ab9242..bda0129b6252 100644 --- a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp @@ -17,6 +17,7 @@ #include "clang/AST/CXXInheritance.h" #include "clang/AST/RecordLayout.h" #include "clang/Basic/CodeGenOptions.h" +#include "clang/CIR/Dialect/IR/CIRTypes.h" #include "clang/CodeGen/CGFunctionInfo.h" #include "clang/CodeGen/ConstantInitBuilder.h" #include "llvm/Support/Format.h" diff --git a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp index bc783f1e3ca9..5c1f1e21148b 100644 --- a/clang/lib/CIR/Dialect/IR/CIRTypes.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRTypes.cpp @@ -95,15 +95,30 @@ void BoolType::print(mlir::AsmPrinter &printer) const {} //===----------------------------------------------------------------------===// Type StructType::parse(mlir::AsmParser &parser) { + const auto loc = parser.getCurrentLocation(); llvm::SmallVector members; mlir::StringAttr id; bool body = false; bool packed = false; mlir::cir::ASTRecordDeclAttr ast = nullptr; + RecordKind kind; if (parser.parseLess()) return {}; + // TODO(cir): in the future we should probably separate types for different + // source language declarations such as cir.class, cir.union, and cir.struct + if (parser.parseOptionalKeyword("struct").succeeded()) + kind = RecordKind::Struct; + else if (parser.parseOptionalKeyword("union").succeeded()) + kind = RecordKind::Union; + else if (parser.parseOptionalKeyword("class").succeeded()) + kind = RecordKind::Class; + else { + parser.emitError(loc, "unknown struct type"); + return {}; + } + if (parser.parseAttribute(id)) return {}; @@ -130,12 +145,26 @@ Type StructType::parse(mlir::AsmParser &parser) { if (parser.parseGreater()) return {}; - return StructType::get(parser.getContext(), members, id, body, packed, + return StructType::get(parser.getContext(), members, id, body, packed, kind, std::nullopt); } void StructType::print(mlir::AsmPrinter &printer) const { - printer << '<' << getTypeName() << " "; + printer << '<'; + + switch (getKind()) { + case RecordKind::Struct: + printer << "struct "; + break; + case RecordKind::Union: + printer << "union "; + break; + case RecordKind::Class: + printer << "class "; + break; + } + + printer << getTypeName() << " "; if (getPacked()) printer << "packed "; diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 20ccc98c13f7..846caf23fafb 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -1823,7 +1823,7 @@ void prepareTypeConverter(mlir::LLVMTypeConverter &converter) { mlir::LLVM::LLVMStructType llvmStruct; if (type.getTypeName().size() != 0) { llvmStruct = mlir::LLVM::LLVMStructType::getIdentified( - type.getContext(), type.getTypeName()); + type.getContext(), type.getPrefixedName()); if (llvmStruct.setBody(llvmMembers, /*isPacked=*/type.getPacked()) .failed()) llvm_unreachable("Failed to set body of struct"); diff --git a/clang/test/CIR/CodeGen/String.cpp b/clang/test/CIR/CodeGen/String.cpp index 81c179f6b7c3..bdacc31a382e 100644 --- a/clang/test/CIR/CodeGen/String.cpp +++ b/clang/test/CIR/CodeGen/String.cpp @@ -18,20 +18,20 @@ void test() { } // CHECK: cir.func linkonce_odr @_ZN6StringC2Ev -// CHECK-NEXT: %0 = cir.alloca !cir.ptr +// CHECK-NEXT: %0 = cir.alloca !cir.ptr // CHECK-NEXT: cir.store %arg0, %0 // CHECK-NEXT: %1 = cir.load %0 // CHECK-NEXT: %2 = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "storage"}> // CHECK-NEXT: %3 = cir.const(#cir.null : !cir.ptr) : !cir.ptr // CHECK-NEXT: cir.store %3, %2 : !cir.ptr, cir.ptr > -// CHECK-NEXT: %4 = "cir.struct_element_addr"(%1) <{member_index = 1 : index, member_name = "size"}> : (!cir.ptr) -> !cir.ptr +// CHECK-NEXT: %4 = "cir.struct_element_addr"(%1) <{member_index = 1 : index, member_name = "size"}> : (!cir.ptr) -> !cir.ptr // CHECK-NEXT: %5 = cir.const(#cir.int<0> : !s32i) : !s32i // CHECK-NEXT: %6 = cir.cast(integral, %5 : !s32i), !s64i // CHECK-NEXT: cir.store %6, %4 : !s64i, cir.ptr // CHECK-NEXT: cir.return // CHECK-NEXT: } // CHECK: cir.func linkonce_odr @_ZN6StringC2Ei -// CHECK-NEXT: %0 = cir.alloca !cir.ptr +// CHECK-NEXT: %0 = cir.alloca !cir.ptr // CHECK-NEXT: %1 = cir.alloca !s32i, cir.ptr , ["size", init] // CHECK-NEXT: cir.store %arg0, %0 // CHECK-NEXT: cir.store %arg1, %1 @@ -39,7 +39,7 @@ void test() { // CHECK-NEXT: %3 = "cir.struct_element_addr"(%2) <{member_index = 0 : index, member_name = "storage"}> // CHECK-NEXT: %4 = cir.const(#cir.null : !cir.ptr) // CHECK-NEXT: cir.store %4, %3 -// CHECK-NEXT: %5 = "cir.struct_element_addr"(%2) <{member_index = 1 : index, member_name = "size"}> : (!cir.ptr) -> !cir.ptr +// CHECK-NEXT: %5 = "cir.struct_element_addr"(%2) <{member_index = 1 : index, member_name = "size"}> : (!cir.ptr) -> !cir.ptr // CHECK-NEXT: %6 = cir.load %1 : cir.ptr , !s32i // CHECK-NEXT: %7 = cir.cast(integral, %6 : !s32i), !s64i // CHECK-NEXT: cir.store %7, %5 : !s64i, cir.ptr @@ -47,27 +47,27 @@ void test() { // CHECK-NEXT: } // CHECK: cir.func linkonce_odr @_ZN6StringC2EPKc -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} // CHECK-NEXT: %1 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK-NEXT: cir.store %arg1, %1 : !cir.ptr, cir.ptr > -// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr -// CHECK-NEXT: %3 = "cir.struct_element_addr"(%2) <{member_index = 0 : index, member_name = "storage"}> : (!cir.ptr) -> !cir.ptr> +// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK-NEXT: %3 = "cir.struct_element_addr"(%2) <{member_index = 0 : index, member_name = "storage"}> : (!cir.ptr) -> !cir.ptr> // CHECK-NEXT: %4 = cir.const(#cir.null : !cir.ptr) : !cir.ptr // CHECK-NEXT: cir.store %4, %3 : !cir.ptr, cir.ptr > // CHECK-NEXT: cir.return // CHECK: cir.func linkonce_odr @_ZN6StringC1EPKc -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} // CHECK-NEXT: %1 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK-NEXT: cir.store %arg1, %1 : !cir.ptr, cir.ptr > -// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK-NEXT: %3 = cir.load %1 : cir.ptr >, !cir.ptr -// CHECK-NEXT: cir.call @_ZN6StringC2EPKc(%2, %3) : (!cir.ptr, !cir.ptr) -> () +// CHECK-NEXT: cir.call @_ZN6StringC2EPKc(%2, %3) : (!cir.ptr, !cir.ptr) -> () // CHECK-NEXT: cir.return // CHECK: cir.func @_Z4testv() -// CHECK: cir.call @_ZN6StringC1Ev(%0) : (!cir.ptr) -> () -// CHECK: cir.call @_ZN6StringC1Ei(%1, %3) : (!cir.ptr, !s32i) -> () -// CHECK: cir.call @_ZN6StringC1EPKc(%2, %5) : (!cir.ptr, !cir.ptr) -> () +// CHECK: cir.call @_ZN6StringC1Ev(%0) : (!cir.ptr) -> () +// CHECK: cir.call @_ZN6StringC1Ei(%1, %3) : (!cir.ptr, !s32i) -> () +// CHECK: cir.call @_ZN6StringC1EPKc(%2, %5) : (!cir.ptr, !cir.ptr) -> () diff --git a/clang/test/CIR/CodeGen/agg-init.cpp b/clang/test/CIR/CodeGen/agg-init.cpp index 8b5596adcbb2..0df739611a90 100644 --- a/clang/test/CIR/CodeGen/agg-init.cpp +++ b/clang/test/CIR/CodeGen/agg-init.cpp @@ -1,8 +1,8 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++17 -fclangir-enable -Wno-unused-value -emit-cir %s -o %t.cir // RUN: FileCheck --input-file=%t.cir %s -// CHECK: !ty_22struct2EZero22 = !cir.struct<"struct.Zero" {!u8i}> -// CHECK: !ty_22struct2Eyep_22 = !cir.struct<"struct.yep_" {!u32i, !u32i}> +// CHECK: !ty_22Zero22 = !cir.struct +// CHECK: !ty_22yep_22 = !cir.struct struct Zero { void yolo(); @@ -15,9 +15,9 @@ void f() { } // CHECK: cir.func @_Z1fv() -// CHECK: %0 = cir.alloca !ty_22struct2EZero22, cir.ptr , ["z0", init] -// CHECK: %1 = cir.alloca !ty_22struct2EZero22, cir.ptr , ["z1"] -// CHECK: cir.call @_ZN4ZeroC1Ev(%0) : (!cir.ptr) -> () +// CHECK: %0 = cir.alloca !ty_22Zero22, cir.ptr , ["z0", init] +// CHECK: %1 = cir.alloca !ty_22Zero22, cir.ptr , ["z1"] +// CHECK: cir.call @_ZN4ZeroC1Ev(%0) : (!cir.ptr) -> () // CHECK: cir.return typedef enum xxy_ { @@ -34,11 +34,11 @@ typedef struct yep_ { void use() { yop{}; } // CHECK: cir.func @_Z3usev() -// CHECK: %0 = cir.alloca !ty_22struct2Eyep_22, cir.ptr , ["agg.tmp0"] {alignment = 4 : i64} -// CHECK: %1 = "cir.struct_element_addr"(%0) <{member_index = 0 : index, member_name = "Status"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %0 = cir.alloca !ty_22yep_22, cir.ptr , ["agg.tmp0"] {alignment = 4 : i64} +// CHECK: %1 = "cir.struct_element_addr"(%0) <{member_index = 0 : index, member_name = "Status"}> : (!cir.ptr) -> !cir.ptr // CHECK: %2 = cir.const(#cir.int<0> : !u32i) : !u32i // CHECK: cir.store %2, %1 : !u32i, cir.ptr -// CHECK: %3 = "cir.struct_element_addr"(%0) <{member_index = 1 : index, member_name = "HC"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %3 = "cir.struct_element_addr"(%0) <{member_index = 1 : index, member_name = "HC"}> : (!cir.ptr) -> !cir.ptr // CHECK: %4 = cir.const(#cir.int<0> : !u32i) : !u32i // CHECK: cir.store %4, %3 : !u32i, cir.ptr // CHECK: cir.return @@ -64,16 +64,16 @@ void yo() { } // CHECK: cir.func @_Z2yov() -// CHECK: %0 = cir.alloca !ty_22struct2EYo22, cir.ptr , ["ext"] {alignment = 8 : i64} -// CHECK: %1 = cir.alloca !ty_22struct2EYo22, cir.ptr , ["ext2", init] {alignment = 8 : i64} -// CHECK: %2 = cir.const(#cir.const_struct<{#cir.int<1000070000> : !u32i, #cir.null : !cir.ptr, #cir.int<0> : !u64i}> : !ty_22struct2EYo22) : !ty_22struct2EYo22 -// CHECK: cir.store %2, %0 : !ty_22struct2EYo22, cir.ptr -// CHECK: %3 = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "type"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %0 = cir.alloca !ty_22Yo22, cir.ptr , ["ext"] {alignment = 8 : i64} +// CHECK: %1 = cir.alloca !ty_22Yo22, cir.ptr , ["ext2", init] {alignment = 8 : i64} +// CHECK: %2 = cir.const(#cir.const_struct<{#cir.int<1000070000> : !u32i, #cir.null : !cir.ptr, #cir.int<0> : !u64i}> : !ty_22Yo22) : !ty_22Yo22 +// CHECK: cir.store %2, %0 : !ty_22Yo22, cir.ptr +// CHECK: %3 = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "type"}> : (!cir.ptr) -> !cir.ptr // CHECK: %4 = cir.const(#cir.int<1000066001> : !u32i) : !u32i // CHECK: cir.store %4, %3 : !u32i, cir.ptr -// CHECK: %5 = "cir.struct_element_addr"(%1) <{member_index = 1 : index, member_name = "next"}> : (!cir.ptr) -> !cir.ptr> -// CHECK: %6 = cir.cast(bitcast, %0 : !cir.ptr), !cir.ptr +// CHECK: %5 = "cir.struct_element_addr"(%1) <{member_index = 1 : index, member_name = "next"}> : (!cir.ptr) -> !cir.ptr> +// CHECK: %6 = cir.cast(bitcast, %0 : !cir.ptr), !cir.ptr // CHECK: cir.store %6, %5 : !cir.ptr, cir.ptr > -// CHECK: %7 = "cir.struct_element_addr"(%1) <{member_index = 2 : index, member_name = "createFlags"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %7 = "cir.struct_element_addr"(%1) <{member_index = 2 : index, member_name = "createFlags"}> : (!cir.ptr) -> !cir.ptr // CHECK: %8 = cir.const(#cir.int<0> : !u64i) : !u64i // CHECK: cir.store %8, %7 : !u64i, cir.ptr diff --git a/clang/test/CIR/CodeGen/array.c b/clang/test/CIR/CodeGen/array.c index e0f23021dcaf..eee163f8980f 100644 --- a/clang/test/CIR/CodeGen/array.c +++ b/clang/test/CIR/CodeGen/array.c @@ -5,4 +5,4 @@ struct S { int i; } arr[3] = {{1}}; -// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES22, #cir.zero : !ty_22struct2ES22, #cir.zero : !ty_22struct2ES22]> : !cir.array +// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S22, #cir.zero : !ty_22S22, #cir.zero : !ty_22S22]> : !cir.array diff --git a/clang/test/CIR/CodeGen/array.cpp b/clang/test/CIR/CodeGen/array.cpp index 44395ee08feb..55c972bf0971 100644 --- a/clang/test/CIR/CodeGen/array.cpp +++ b/clang/test/CIR/CodeGen/array.cpp @@ -70,7 +70,7 @@ int globalNullArr[] = {0, 0}; struct S { int i; } arr[3] = {{1}}; -// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES22, #cir.zero : !ty_22struct2ES22, #cir.zero : !ty_22struct2ES22]> : !cir.array +// CHECK: cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S22, #cir.zero : !ty_22S22, #cir.zero : !ty_22S22]> : !cir.array void testPointerDecaySubscriptAccess(int arr[]) { // CHECK: cir.func @{{.+}}testPointerDecaySubscriptAccess diff --git a/clang/test/CIR/CodeGen/assign-operator.cpp b/clang/test/CIR/CodeGen/assign-operator.cpp index 44d9a84c5cc6..4eb1e5a447f4 100644 --- a/clang/test/CIR/CodeGen/assign-operator.cpp +++ b/clang/test/CIR/CodeGen/assign-operator.cpp @@ -15,11 +15,11 @@ struct String { // StringView::StringView(String const&) // // CHECK: cir.func linkonce_odr @_ZN10StringViewC2ERK6String - // CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} - // CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} - // CHECK: cir.store %arg0, %0 : !cir.ptr - // CHECK: cir.store %arg1, %1 : !cir.ptr - // CHECK: %2 = cir.load %0 : cir.ptr > + // CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} + // CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} + // CHECK: cir.store %arg0, %0 : !cir.ptr + // CHECK: cir.store %arg1, %1 : !cir.ptr + // CHECK: %2 = cir.load %0 : cir.ptr > // Get address of `this->size` @@ -27,7 +27,7 @@ struct String { // Get address of `s` - // CHECK: %4 = cir.load %1 : cir.ptr > + // CHECK: %4 = cir.load %1 : cir.ptr > // Get the address of s.size @@ -41,25 +41,25 @@ struct String { // CHECK: } // DISABLE: cir.func linkonce_odr @_ZN10StringViewC2ERK6String - // DISABLE-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} + // DISABLE-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} // StringView::operator=(StringView&&) // // CHECK: cir.func linkonce_odr @_ZN10StringViewaSEOS_ - // CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} - // CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["", init] {alignment = 8 : i64} - // CHECK: %2 = cir.alloca !cir.ptr, cir.ptr >, ["__retval"] {alignment = 8 : i64} - // CHECK: cir.store %arg0, %0 : !cir.ptr - // CHECK: cir.store %arg1, %1 : !cir.ptr - // CHECK: %3 = cir.load deref %0 : cir.ptr > - // CHECK: %4 = cir.load %1 : cir.ptr > + // CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} + // CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["", init] {alignment = 8 : i64} + // CHECK: %2 = cir.alloca !cir.ptr, cir.ptr >, ["__retval"] {alignment = 8 : i64} + // CHECK: cir.store %arg0, %0 : !cir.ptr + // CHECK: cir.store %arg1, %1 : !cir.ptr + // CHECK: %3 = cir.load deref %0 : cir.ptr > + // CHECK: %4 = cir.load %1 : cir.ptr > // CHECK: %5 = "cir.struct_element_addr"(%4) <{member_index = 0 : index, member_name = "size"}> // CHECK: %6 = cir.load %5 : cir.ptr , !s64i // CHECK: %7 = "cir.struct_element_addr"(%3) <{member_index = 0 : index, member_name = "size"}> // CHECK: cir.store %6, %7 : !s64i, cir.ptr - // CHECK: cir.store %3, %2 : !cir.ptr - // CHECK: %8 = cir.load %2 : cir.ptr > - // CHECK: cir.return %8 : !cir.ptr + // CHECK: cir.store %3, %2 : !cir.ptr + // CHECK: %8 = cir.load %2 : cir.ptr > + // CHECK: cir.return %8 : !cir.ptr // CHECK: } // DISABLE: cir.func private @_ZN10StringViewaSEOS_ @@ -83,17 +83,17 @@ int main() { // CHECK: cir.func @main() -> !s32i // CHECK: %0 = cir.alloca !s32i, cir.ptr , ["__retval"] {alignment = 4 : i64} -// CHECK: %1 = cir.alloca !ty_22struct2EStringView22, cir.ptr , ["sv", init] {alignment = 8 : i64} -// CHECK: cir.call @_ZN10StringViewC2Ev(%1) : (!cir.ptr) -> () +// CHECK: %1 = cir.alloca !ty_22StringView22, cir.ptr , ["sv", init] {alignment = 8 : i64} +// CHECK: cir.call @_ZN10StringViewC2Ev(%1) : (!cir.ptr) -> () // CHECK: cir.scope { -// CHECK: %3 = cir.alloca !ty_22struct2EString22, cir.ptr , ["s", init] {alignment = 8 : i64} +// CHECK: %3 = cir.alloca !ty_22String22, cir.ptr , ["s", init] {alignment = 8 : i64} // CHECK: %4 = cir.get_global @".str" : cir.ptr > // CHECK: %5 = cir.cast(array_to_ptrdecay, %4 : !cir.ptr>), !cir.ptr -// CHECK: cir.call @_ZN6StringC2EPKc(%3, %5) : (!cir.ptr, !cir.ptr) -> () +// CHECK: cir.call @_ZN6StringC2EPKc(%3, %5) : (!cir.ptr, !cir.ptr) -> () // CHECK: cir.scope { -// CHECK: %6 = cir.alloca !ty_22struct2EStringView22, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} -// CHECK: cir.call @_ZN10StringViewC2ERK6String(%6, %3) : (!cir.ptr, !cir.ptr) -> () -// CHECK: %7 = cir.call @_ZN10StringViewaSEOS_(%1, %6) : (!cir.ptr, !cir.ptr) -> !cir.ptr +// CHECK: %6 = cir.alloca !ty_22StringView22, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} +// CHECK: cir.call @_ZN10StringViewC2ERK6String(%6, %3) : (!cir.ptr, !cir.ptr) -> () +// CHECK: %7 = cir.call @_ZN10StringViewaSEOS_(%1, %6) : (!cir.ptr, !cir.ptr) -> !cir.ptr // CHECK: } // CHECK: } // CHECK: %2 = cir.load %0 : cir.ptr , !s32i diff --git a/clang/test/CIR/CodeGen/atomic.cpp b/clang/test/CIR/CodeGen/atomic.cpp index 72c3b13905a7..0282462449c4 100644 --- a/clang/test/CIR/CodeGen/atomic.cpp +++ b/clang/test/CIR/CodeGen/atomic.cpp @@ -7,4 +7,4 @@ typedef struct _a { void m() { at y; } -// CHECK: !ty_22struct2E_a22 = !cir.struct<"struct._a" {!s32i}> \ No newline at end of file +// CHECK: !ty_22_a22 = !cir.struct \ No newline at end of file diff --git a/clang/test/CIR/CodeGen/bitfields.cpp b/clang/test/CIR/CodeGen/bitfields.cpp index bbacc920e071..c1f801af1e7c 100644 --- a/clang/test/CIR/CodeGen/bitfields.cpp +++ b/clang/test/CIR/CodeGen/bitfields.cpp @@ -14,5 +14,5 @@ void m() { __long l; } -// CHECK: !ty_22struct2Eanon22 = !cir.struct<"struct.anon" {!u32i} #cir.recdecl.ast> -// CHECK: !ty_22struct2E__long22 = !cir.struct<"struct.__long" {!ty_22struct2Eanon22, !u32i, !cir.ptr}> \ No newline at end of file +// CHECK: !ty_22anon22 = !cir.struct +// CHECK: !ty_22__long22 = !cir.struct}> diff --git a/clang/test/CIR/CodeGen/build-deferred.cpp b/clang/test/CIR/CodeGen/build-deferred.cpp index 101fd45c6473..27b816f19054 100644 --- a/clang/test/CIR/CodeGen/build-deferred.cpp +++ b/clang/test/CIR/CodeGen/build-deferred.cpp @@ -24,4 +24,4 @@ void test() { // CHECK-NOT: cir.func linkonce_odr @_ZN6StringC1EPKc // CHECK: cir.func @_Z4testv() -// CHECK: cir.call @_ZN6StringC1Ev(%0) : (!cir.ptr) -> () \ No newline at end of file +// CHECK: cir.call @_ZN6StringC1Ev(%0) : (!cir.ptr) -> () \ No newline at end of file diff --git a/clang/test/CIR/CodeGen/cond.cpp b/clang/test/CIR/CodeGen/cond.cpp index c16a84d18bac..95443c11a3dc 100644 --- a/clang/test/CIR/CodeGen/cond.cpp +++ b/clang/test/CIR/CodeGen/cond.cpp @@ -17,11 +17,11 @@ min(const unsigned long& __a, const unsigned long& __b) { // CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK: cir.store %arg1, %1 : !cir.ptr, cir.ptr > // CHECK: cir.scope { -// CHECK: %4 = cir.alloca !ty_22struct2E__less22, cir.ptr , ["ref.tmp0"] {alignment = 1 : i64} -// CHECK: cir.call @_ZN6__lessC1Ev(%4) : (!cir.ptr) -> () +// CHECK: %4 = cir.alloca !ty_22__less22, cir.ptr , ["ref.tmp0"] {alignment = 1 : i64} +// CHECK: cir.call @_ZN6__lessC1Ev(%4) : (!cir.ptr) -> () // CHECK: %5 = cir.load %1 : cir.ptr >, !cir.ptr // CHECK: %6 = cir.load %0 : cir.ptr >, !cir.ptr -// CHECK: %7 = cir.call @_ZNK6__lessclERKmS1_(%4, %5, %6) : (!cir.ptr, !cir.ptr, !cir.ptr) -> !cir.bool +// CHECK: %7 = cir.call @_ZNK6__lessclERKmS1_(%4, %5, %6) : (!cir.ptr, !cir.ptr, !cir.ptr) -> !cir.bool // CHECK: %8 = cir.ternary(%7, true { // CHECK: %9 = cir.load %1 : cir.ptr >, !cir.ptr // CHECK: cir.yield %9 : !cir.ptr diff --git a/clang/test/CIR/CodeGen/coro-task.cpp b/clang/test/CIR/CodeGen/coro-task.cpp index 367d2403c753..dd4b7394d898 100644 --- a/clang/test/CIR/CodeGen/coro-task.cpp +++ b/clang/test/CIR/CodeGen/coro-task.cpp @@ -126,16 +126,16 @@ co_invoke_fn co_invoke; }} // namespace folly::coro -// CHECK: ![[VoidTask:ty_.*]] = !cir.struct<"struct.folly::coro::Task" {!u8i}> -// CHECK: ![[IntTask:ty_.*]] = !cir.struct<"struct.folly::coro::Task" {!u8i}> -// CHECK: ![[VoidPromisse:ty_.*]] = !cir.struct<"struct.folly::coro::Task::promise_type" {!u8i}> -// CHECK: ![[CoroHandleVoid:ty_.*]] = !cir.struct<"struct.std::coroutine_handle" {!u8i}> -// CHECK: ![[CoroHandlePromise:ty_.*]] = !cir.struct<"struct.std::coroutine_handle" {!u8i}> -// CHECK: ![[StdString:ty_.*]] = !cir.struct<"struct.std::string" {!u8i} -// CHECK: ![[SuspendAlways:ty_.*]] = !cir.struct<"struct.std::suspend_always" {!u8i}> +// CHECK: ![[VoidTask:ty_.*]] = !cir.struct +// CHECK: ![[IntTask:ty_.*]] = !cir.struct +// CHECK: ![[VoidPromisse:ty_.*]] = !cir.struct::promise_type" {!u8i}> +// CHECK: ![[CoroHandleVoid:ty_.*]] = !cir.struct +// CHECK: ![[CoroHandlePromise:ty_.*]] = !cir.struct +// CHECK: ![[StdString:ty_.*]] = !cir.struct // CHECK: module {{.*}} { -// CHECK-NEXT: cir.global external @_ZN5folly4coro9co_invokeE = #cir.zero : !ty_22struct2Efolly3A3Acoro3A3Aco_invoke_fn22 +// CHECK-NEXT: cir.global external @_ZN5folly4coro9co_invokeE = #cir.zero : !ty_22folly3A3Acoro3A3Aco_invoke_fn22 // CHECK: cir.func builtin private @__builtin_coro_id(!u32i, !cir.ptr, !cir.ptr, !cir.ptr) -> !u32i // CHECK: cir.func builtin private @__builtin_coro_alloc(!u32i) -> !cir.bool @@ -359,23 +359,23 @@ folly::coro::Task go4() { // CHECK: } // CHECK: %12 = cir.scope { -// CHECK: %17 = cir.alloca !ty_22class2Eanon221, cir.ptr , ["ref.tmp1"] {alignment = 1 : i64} +// CHECK: %17 = cir.alloca !ty_22anon221, 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: %19 = cir.unary(plus, %18) : !cir.ptr)>>, !cir.ptr)>> -// CHECK: cir.yield %19 : !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: } -// CHECK: cir.store %12, %3 : !cir.ptr)>>, cir.ptr )>>> +// CHECK: cir.store %12, %3 : !cir.ptr)>>, cir.ptr )>>> // CHECK: cir.scope { // CHECK: %17 = cir.alloca !s32i, cir.ptr , ["ref.tmp2", init] {alignment = 4 : i64} -// CHECK: %18 = cir.load %3 : cir.ptr )>>>, !cir.ptr)>> +// CHECK: %18 = cir.load %3 : cir.ptr )>>>, !cir.ptr)>> // CHECK: %19 = cir.const(#cir.int<3> : !s32i) : !s32i // CHECK: cir.store %19, %17 : !s32i, cir.ptr // Call invoker, which calls operator() indirectly. -// CHECK: %20 = cir.call %18(%17) : (!cir.ptr)>>, !cir.ptr) -> !ty_22struct2Efolly3A3Acoro3A3ATask221 -// CHECK: cir.store %20, %4 : !ty_22struct2Efolly3A3Acoro3A3ATask221, cir.ptr +// CHECK: %20 = cir.call %18(%17) : (!cir.ptr)>>, !cir.ptr) -> !ty_22folly3A3Acoro3A3ATask221 +// CHECK: cir.store %20, %4 : !ty_22folly3A3Acoro3A3ATask221, cir.ptr // CHECK: } // CHECK: cir.await(user, ready : { diff --git a/clang/test/CIR/CodeGen/ctor-alias.cpp b/clang/test/CIR/CodeGen/ctor-alias.cpp index a84272157c56..09512bce004c 100644 --- a/clang/test/CIR/CodeGen/ctor-alias.cpp +++ b/clang/test/CIR/CodeGen/ctor-alias.cpp @@ -9,20 +9,20 @@ void t() { } // CHECK: cir.func linkonce_odr @_ZN11DummyStringC2EPKc -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} // CHECK-NEXT: %1 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK-NEXT: cir.store %arg1, %1 : !cir.ptr, cir.ptr > -// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK-NEXT: cir.return // CHECK-NOT: cir.fun @_ZN11DummyStringC1EPKc // CHECK: cir.func @_Z1tv -// CHECK-NEXT: %0 = cir.alloca !ty_22struct2EDummyString22, cir.ptr , ["s4", init] {alignment = 1 : i64} +// CHECK-NEXT: %0 = cir.alloca !ty_22DummyString22, cir.ptr , ["s4", init] {alignment = 1 : i64} // CHECK-NEXT: %1 = cir.get_global @".str" : cir.ptr > // CHECK-NEXT: %2 = cir.cast(array_to_ptrdecay, %1 : !cir.ptr>), !cir.ptr -// CHECK-NEXT: cir.call @_ZN11DummyStringC2EPKc(%0, %2) : (!cir.ptr, !cir.ptr) -> () +// CHECK-NEXT: cir.call @_ZN11DummyStringC2EPKc(%0, %2) : (!cir.ptr, !cir.ptr) -> () // CHECK-NEXT: cir.return struct B { @@ -31,10 +31,10 @@ struct B { B::B() { } -// CHECK: cir.func @_ZN1BC2Ev(%arg0: !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: cir.func @_ZN1BC2Ev(%arg0: !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: cir.return // CHECK: } -// CHECK: cir.func @_ZN1BC1Ev(!cir.ptr) alias(@_ZN1BC2Ev) \ No newline at end of file +// CHECK: cir.func @_ZN1BC1Ev(!cir.ptr) alias(@_ZN1BC2Ev) \ No newline at end of file diff --git a/clang/test/CIR/CodeGen/ctor-member-lvalue-to-rvalue.cpp b/clang/test/CIR/CodeGen/ctor-member-lvalue-to-rvalue.cpp index 77240b8e04f9..617adc524d40 100644 --- a/clang/test/CIR/CodeGen/ctor-member-lvalue-to-rvalue.cpp +++ b/clang/test/CIR/CodeGen/ctor-member-lvalue-to-rvalue.cpp @@ -6,8 +6,8 @@ struct String { long size; String(const String &s) : size{s.size} {} // CHECK: cir.func linkonce_odr @_ZN6StringC2ERKS_ -// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} -// CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} +// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} // CHECK: cir.store %arg0, %0 // CHECK: cir.store %arg1, %1 // CHECK: %2 = cir.load %0 @@ -28,10 +28,10 @@ void foo() { // FIXME: s1 shouldn't be uninitialized. // cir.func @_Z3foov() { - // %0 = cir.alloca !ty_22struct2EString22, cir.ptr , ["s"] {alignment = 8 : i64} - // %1 = cir.alloca !ty_22struct2EString22, cir.ptr , ["s1"] {alignment = 8 : i64} - // cir.call @_ZN6StringC2Ev(%0) : (!cir.ptr) -> () - // cir.call @_ZN6StringC2ERKS_(%1, %0) : (!cir.ptr, !cir.ptr) -> () + // %0 = cir.alloca !ty_22String22, cir.ptr , ["s"] {alignment = 8 : i64} + // %1 = cir.alloca !ty_22String22, cir.ptr , ["s1"] {alignment = 8 : i64} + // cir.call @_ZN6StringC2Ev(%0) : (!cir.ptr) -> () + // cir.call @_ZN6StringC2ERKS_(%1, %0) : (!cir.ptr, !cir.ptr) -> () // cir.return // } } diff --git a/clang/test/CIR/CodeGen/ctor.cpp b/clang/test/CIR/CodeGen/ctor.cpp index 897535ca9f21..05cd694f9d42 100644 --- a/clang/test/CIR/CodeGen/ctor.cpp +++ b/clang/test/CIR/CodeGen/ctor.cpp @@ -11,22 +11,22 @@ void baz() { Struk s; } -// CHECK: !ty_22struct2EStruk22 = !cir.struct<"struct.Struk" {!s32i}> +// CHECK: !ty_22Struk22 = !cir.struct -// CHECK: cir.func linkonce_odr @_ZN5StrukC2Ev(%arg0: !cir.ptr -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > -// CHECK-NEXT: %1 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK: cir.func linkonce_odr @_ZN5StrukC2Ev(%arg0: !cir.ptr +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: %1 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK-NEXT: cir.return -// CHECK: cir.func linkonce_odr @_ZN5StrukC1Ev(%arg0: !cir.ptr -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > -// CHECK-NEXT: %1 = cir.load %0 : cir.ptr >, !cir.ptr -// CHECK-NEXT: cir.call @_ZN5StrukC2Ev(%1) : (!cir.ptr) -> () +// CHECK: cir.func linkonce_odr @_ZN5StrukC1Ev(%arg0: !cir.ptr +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: %1 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK-NEXT: cir.call @_ZN5StrukC2Ev(%1) : (!cir.ptr) -> () // CHECK-NEXT: cir.return // CHECK: cir.func @_Z3bazv() -// CHECK-NEXT: %0 = cir.alloca !ty_22struct2EStruk22, cir.ptr , ["s", init] {alignment = 4 : i64} -// CHECK-NEXT: cir.call @_ZN5StrukC1Ev(%0) : (!cir.ptr) -> () +// CHECK-NEXT: %0 = cir.alloca !ty_22Struk22, cir.ptr , ["s", init] {alignment = 4 : i64} +// CHECK-NEXT: cir.call @_ZN5StrukC1Ev(%0) : (!cir.ptr) -> () // CHECK-NEXT: cir.return diff --git a/clang/test/CIR/CodeGen/derived-to-base.cpp b/clang/test/CIR/CodeGen/derived-to-base.cpp index df8cb3a0fa4d..692b1146d485 100644 --- a/clang/test/CIR/CodeGen/derived-to-base.cpp +++ b/clang/test/CIR/CodeGen/derived-to-base.cpp @@ -75,29 +75,29 @@ void C3::Layer::Initialize() { } } -// CHECK: !ty_22class2EC23A3ALayer22 = !cir.struct<"class.C2::Layer" {!ty_22class2EC13A3ALayer22, !cir.ptr -// CHECK: !ty_22struct2EC33A3ALayer22 = !cir.struct<"struct.C3::Layer" {!ty_22class2EC23A3ALayer22 +// CHECK-DAG: !ty_22C23A3ALayer22 = !cir.struct +// CHECK-DAG: !ty_22C33A3ALayer22 = !cir.struct) -> cir.ptr -// CHECK: %3 = "cir.struct_element_addr"(%2) <{member_index = 0 : index, member_name = "m_C1"}> : (!cir.ptr) -> !cir.ptr> -// CHECK: %4 = cir.load %3 : cir.ptr >, !cir.ptr -// CHECK: %5 = cir.const(#cir.null : !cir.ptr) : !cir.ptr -// CHECK: %6 = cir.cmp(eq, %4, %5) : !cir.ptr, !cir.bool +// CHECK: %2 = cir.base_class_addr(%1 : cir.ptr ) -> cir.ptr +// CHECK: %3 = "cir.struct_element_addr"(%2) <{member_index = 0 : index, member_name = "m_C1"}> : (!cir.ptr) -> !cir.ptr> +// CHECK: %4 = cir.load %3 : cir.ptr >, !cir.ptr +// CHECK: %5 = cir.const(#cir.null : !cir.ptr) : !cir.ptr +// CHECK: %6 = cir.cmp(eq, %4, %5) : !cir.ptr, !cir.bool enumy C3::Initialize() { return C2::Initialize(); } -// CHECK: cir.func @_ZN2C310InitializeEv(%arg0: !cir.ptr -// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK: cir.func @_ZN2C310InitializeEv(%arg0: !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: %2 = cir.load %0 : cir.ptr >, !cir.ptr -// CHECK: %3 = cir.base_class_addr(%2 : cir.ptr ) -> cir.ptr -// CHECK: %4 = cir.call @_ZN2C210InitializeEv(%3) : (!cir.ptr) -> !s32i +// CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK: %2 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK: %3 = cir.base_class_addr(%2 : cir.ptr ) -> cir.ptr +// CHECK: %4 = cir.call @_ZN2C210InitializeEv(%3) : (!cir.ptr) -> !s32i void vcall(C1 &c1) { buffy b; @@ -105,21 +105,21 @@ void vcall(C1 &c1) { c1.SetStuff(e, b); } -// CHECK: cir.func @_Z5vcallR2C1(%arg0: !cir.ptr -// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["c1", init] {alignment = 8 : i64} -// CHECK: %1 = cir.alloca !ty_22struct2Ebuffy22, cir.ptr , ["b"] {alignment = 8 : i64} +// CHECK: cir.func @_Z5vcallR2C1(%arg0: !cir.ptr +// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["c1", init] {alignment = 8 : i64} +// CHECK: %1 = cir.alloca !ty_22buffy22, cir.ptr , ["b"] {alignment = 8 : i64} // CHECK: %2 = cir.alloca !s32i, cir.ptr , ["e"] {alignment = 4 : i64} -// CHECK: %3 = cir.alloca !ty_22struct2Ebuffy22, cir.ptr , ["agg.tmp0"] {alignment = 8 : i64} -// CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > -// CHECK: %4 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK: %3 = cir.alloca !ty_22buffy22, cir.ptr , ["agg.tmp0"] {alignment = 8 : i64} +// CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK: %4 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK: %5 = cir.load %2 : cir.ptr , !s32i -// CHECK: cir.call @_ZN5buffyC2ERKS_(%3, %1) : (!cir.ptr, !cir.ptr) -> () -// CHECK: %6 = cir.load %3 : cir.ptr , !ty_22struct2Ebuffy22 -// CHECK: %7 = cir.cast(bitcast, %4 : !cir.ptr), !cir.ptr, !s32i, !ty_22struct2Ebuffy22)>>>> -// CHECK: %8 = cir.load %7 : cir.ptr , !s32i, !ty_22struct2Ebuffy22)>>>>, !cir.ptr, !s32i, !ty_22struct2Ebuffy22)>>> -// CHECK: %9 = cir.vtable.address_point( %8 : !cir.ptr, !s32i, !ty_22struct2Ebuffy22)>>>, vtable_index = 0, address_point_index = 2) : cir.ptr , !s32i, !ty_22struct2Ebuffy22)>>> -// CHECK: %10 = cir.load %9 : cir.ptr , !s32i, !ty_22struct2Ebuffy22)>>>, !cir.ptr, !s32i, !ty_22struct2Ebuffy22)>> -// CHECK: %11 = cir.call %10(%4, %5, %6) : (!cir.ptr, !s32i, !ty_22struct2Ebuffy22)>>, !cir.ptr, !s32i, !ty_22struct2Ebuffy22) -> !s32i +// CHECK: cir.call @_ZN5buffyC2ERKS_(%3, %1) : (!cir.ptr, !cir.ptr) -> () +// CHECK: %6 = cir.load %3 : cir.ptr , !ty_22buffy22 +// CHECK: %7 = cir.cast(bitcast, %4 : !cir.ptr), !cir.ptr, !s32i, !ty_22buffy22)>>>> +// CHECK: %8 = cir.load %7 : cir.ptr , !s32i, !ty_22buffy22)>>>>, !cir.ptr, !s32i, !ty_22buffy22)>>> +// CHECK: %9 = cir.vtable.address_point( %8 : !cir.ptr, !s32i, !ty_22buffy22)>>>, vtable_index = 0, address_point_index = 2) : cir.ptr , !s32i, !ty_22buffy22)>>> +// CHECK: %10 = cir.load %9 : cir.ptr , !s32i, !ty_22buffy22)>>>, !cir.ptr, !s32i, !ty_22buffy22)>> +// CHECK: %11 = cir.call %10(%4, %5, %6) : (!cir.ptr, !s32i, !ty_22buffy22)>>, !cir.ptr, !s32i, !ty_22buffy22) -> !s32i // CHECK: cir.return // CHECK: } @@ -135,19 +135,19 @@ class B : public A { void foo () { static_cast(*this).foo();} }; -// CHECK: cir.func linkonce_odr @_ZN1B3fooEv(%arg0: !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 deref %0 : cir.ptr >, !cir.ptr +// CHECK: cir.func linkonce_odr @_ZN1B3fooEv(%arg0: !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 deref %0 : cir.ptr >, !cir.ptr // CHECK: cir.scope { -// CHECK: %2 = cir.alloca !ty_22class2EA22, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} -// CHECK: %3 = cir.base_class_addr(%1 : cir.ptr ) -> cir.ptr +// CHECK: %2 = cir.alloca !ty_22A22, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} +// CHECK: %3 = cir.base_class_addr(%1 : cir.ptr ) -> cir.ptr // Call @A::A(A const&) -// CHECK: cir.call @_ZN1AC2ERKS_(%2, %3) : (!cir.ptr, !cir.ptr) -> () +// CHECK: cir.call @_ZN1AC2ERKS_(%2, %3) : (!cir.ptr, !cir.ptr) -> () // Call @A::foo() -// CHECK: cir.call @_ZN1A3fooEv(%2) : (!cir.ptr) -> () +// CHECK: cir.call @_ZN1A3fooEv(%2) : (!cir.ptr) -> () // CHECK: } // CHECK: cir.return // CHECK: } diff --git a/clang/test/CIR/CodeGen/dtors.cpp b/clang/test/CIR/CodeGen/dtors.cpp index 3fd6a7330ac6..7e59a8ec7fbe 100644 --- a/clang/test/CIR/CodeGen/dtors.cpp +++ b/clang/test/CIR/CodeGen/dtors.cpp @@ -37,17 +37,17 @@ class B : public A }; // Class A -// CHECK: ![[ClassA:ty_.*]] = !cir.struct<"class.A" {!cir.ptr>>} #cir.recdecl.ast> +// CHECK: ![[ClassA:ty_.*]] = !cir.struct>>} #cir.recdecl.ast> // Class B -// CHECK: ![[ClassB:ty_.*]] = !cir.struct<"class.B" {![[ClassA]]}> +// CHECK: ![[ClassB:ty_.*]] = !cir.struct // CHECK: cir.func @_Z4bluev() -// CHECK: %0 = cir.alloca !ty_22class2EPSEvent22, cir.ptr , ["p", init] {alignment = 8 : i64} +// CHECK: %0 = cir.alloca !ty_22PSEvent22, cir.ptr , ["p", init] {alignment = 8 : i64} // CHECK: %1 = cir.const(#cir.int<1> : !s32i) : !s32i // CHECK: %2 = cir.get_global @".str" : cir.ptr > // CHECK: %3 = cir.cast(array_to_ptrdecay, %2 : !cir.ptr>), !cir.ptr -// CHECK: cir.call @_ZN7PSEventC1E6EFModePKc(%0, %1, %3) : (!cir.ptr, !s32i, !cir.ptr) -> () +// CHECK: cir.call @_ZN7PSEventC1E6EFModePKc(%0, %1, %3) : (!cir.ptr, !s32i, !cir.ptr) -> () // CHECK: cir.return // CHECK: } diff --git a/clang/test/CIR/CodeGen/globals.c b/clang/test/CIR/CodeGen/globals.c index 2ab1057b523a..b72b0a09b625 100644 --- a/clang/test/CIR/CodeGen/globals.c +++ b/clang/test/CIR/CodeGen/globals.c @@ -34,7 +34,7 @@ struct { int x; int y[2][2]; } nestedTwoDim = {1, {{2, 3}, {4, 5}}}; -// CHECK: cir.global external @nestedTwoDim = #cir.const_struct<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> : !ty_22struct2Eanon22 +// CHECK: cir.global external @nestedTwoDim = #cir.const_struct<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> : !ty_22anon22 // TODO: test tentatives with internal linkage. diff --git a/clang/test/CIR/CodeGen/lambda.cpp b/clang/test/CIR/CodeGen/lambda.cpp index 2a2d7a524b46..33be960d63b1 100644 --- a/clang/test/CIR/CodeGen/lambda.cpp +++ b/clang/test/CIR/CodeGen/lambda.cpp @@ -6,13 +6,13 @@ void fn() { a(); } -// CHECK: !ty_22class2Eanon22 = !cir.struct<"class.anon" {!u8i}> +// CHECK: !ty_22anon22 = !cir.struct // CHECK-DAG: module // CHECK: cir.func lambda internal private @_ZZ2fnvENK3$_0clEv // CHECK: cir.func @_Z2fnv() -// CHECK-NEXT: %0 = cir.alloca !ty_22class2Eanon22, cir.ptr , ["a"] +// CHECK-NEXT: %0 = cir.alloca !ty_22anon22, cir.ptr , ["a"] // CHECK: cir.call @_ZZ2fnvENK3$_0clEv void l0() { @@ -23,15 +23,15 @@ void l0() { // CHECK: cir.func lambda internal private @_ZZ2l0vENK3$_0clEv( -// 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.struct_element_addr"(%1) <{member_index = 0 : index, member_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.struct_element_addr"(%1) <{member_index = 0 : index, member_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) : !s32i // CHECK: %6 = cir.binop(add, %4, %5) : !s32i -// CHECK: %7 = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "i"}> : (!cir.ptr) -> !cir.ptr> +// CHECK: %7 = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_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_22class2Eanon223 -// CHECK: %0 = cir.alloca !ty_22class2Eanon223, cir.ptr , ["__retval"] {alignment = 8 : i64} +// CHECK: cir.func @_Z1gv() -> !ty_22anon223 +// CHECK: %0 = cir.alloca !ty_22anon223, 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) : !s32i // CHECK: cir.store %2, %1 : !s32i, cir.ptr -// CHECK: %3 = "cir.struct_element_addr"(%0) <{member_index = 0 : index, member_name = "i"}> : (!cir.ptr) -> !cir.ptr> +// CHECK: %3 = "cir.struct_element_addr"(%0) <{member_index = 0 : index, member_name = "i"}> : (!cir.ptr) -> !cir.ptr> // CHECK: cir.store %1, %3 : !cir.ptr, cir.ptr > -// CHECK: %4 = cir.load %0 : cir.ptr , !ty_22class2Eanon223 -// CHECK: cir.return %4 : !ty_22class2Eanon223 +// CHECK: %4 = cir.load %0 : cir.ptr , !ty_22anon223 +// CHECK: cir.return %4 : !ty_22anon223 auto g2() { int i = 12; @@ -65,15 +65,15 @@ auto g2() { } // Should be same as above because of NRVO -// CHECK: cir.func @_Z2g2v() -> !ty_22class2Eanon224 -// CHECK-NEXT: %0 = cir.alloca !ty_22class2Eanon224, cir.ptr , ["__retval", init] {alignment = 8 : i64} +// CHECK: cir.func @_Z2g2v() -> !ty_22anon224 +// CHECK-NEXT: %0 = cir.alloca !ty_22anon224, 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) : !s32i // CHECK-NEXT: cir.store %2, %1 : !s32i, cir.ptr -// CHECK-NEXT: %3 = "cir.struct_element_addr"(%0) <{member_index = 0 : index, member_name = "i"}> : (!cir.ptr) -> !cir.ptr> +// CHECK-NEXT: %3 = "cir.struct_element_addr"(%0) <{member_index = 0 : index, member_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_22class2Eanon224 -// CHECK-NEXT: cir.return %4 : !ty_22class2Eanon224 +// CHECK-NEXT: %4 = cir.load %0 : cir.ptr , !ty_22anon224 +// CHECK-NEXT: cir.return %4 : !ty_22anon224 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_22class2Eanon224, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} -// CHECK-NEXT: %3 = cir.call @_Z2g2v() : () -> !ty_22class2Eanon224 -// CHECK-NEXT: cir.store %3, %2 : !ty_22class2Eanon224, cir.ptr -// CHECK-NEXT: %4 = cir.call @_ZZ2g2vENK3$_0clEv(%2) : (!cir.ptr) -> !s32i +// CHECK-NEXT: %2 = cir.alloca !ty_22anon224, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} +// CHECK-NEXT: %3 = cir.call @_Z2g2v() : () -> !ty_22anon224 +// CHECK-NEXT: cir.store %3, %2 : !ty_22anon224, 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_22class2Eanon221, cir.ptr , ["ref.tmp0"] {alignment = 1 : i64} -// CHECK: %8 = cir.call @_ZZ2g3vENK3$_0cvPFiRKiEEv(%7) : (!cir.ptr) -> !cir.ptr)>> +// CHECK: %7 = cir.alloca !ty_22anon221, 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/libcall.cpp b/clang/test/CIR/CodeGen/libcall.cpp index ea3398b4bb1f..949c165bccde 100644 --- a/clang/test/CIR/CodeGen/libcall.cpp +++ b/clang/test/CIR/CodeGen/libcall.cpp @@ -59,5 +59,5 @@ void t(const char* fmt, ...) { // CHECK: %10 = cir.load %1 : cir.ptr , !u64i // CHECK: %11 = cir.load %3 : cir.ptr >, !cir.ptr -// CHECK: %12 = cir.load %4 : cir.ptr >, !cir.ptr +// CHECK: %12 = cir.load %4 : cir.ptr >, !cir.ptr // CHECK: %13 = cir.call @__vsnprintf_chk(%6, %8, %9, %10, %11, %12) \ No newline at end of file diff --git a/clang/test/CIR/CodeGen/lvalue-refs.cpp b/clang/test/CIR/CodeGen/lvalue-refs.cpp index ecf78a23e225..26ca68761cb0 100644 --- a/clang/test/CIR/CodeGen/lvalue-refs.cpp +++ b/clang/test/CIR/CodeGen/lvalue-refs.cpp @@ -6,8 +6,8 @@ struct String { void split(String &S) {} -// CHECK: cir.func @_Z5splitR6String(%arg0: !cir.ptr -// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["S", init] +// CHECK: cir.func @_Z5splitR6String(%arg0: !cir.ptr +// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["S", init] void foo() { String s; @@ -15,5 +15,5 @@ void foo() { } // CHECK: cir.func @_Z3foov() -// CHECK: %0 = cir.alloca !ty_22struct2EString22, cir.ptr , ["s"] -// CHECK: cir.call @_Z5splitR6String(%0) : (!cir.ptr) -> () +// CHECK: %0 = cir.alloca !ty_22String22, cir.ptr , ["s"] +// CHECK: cir.call @_Z5splitR6String(%0) : (!cir.ptr) -> () diff --git a/clang/test/CIR/CodeGen/move.cpp b/clang/test/CIR/CodeGen/move.cpp index 2f8856e23e37..1be0869d6166 100644 --- a/clang/test/CIR/CodeGen/move.cpp +++ b/clang/test/CIR/CodeGen/move.cpp @@ -16,7 +16,7 @@ struct string { } // std namespace -// CHECK: ![[StdString:ty_.*]] = !cir.struct<"struct.std::string" {!u8i}> +// CHECK: ![[StdString:ty_.*]] = !cir.struct std::string getstr(); void emplace(std::string &&s); diff --git a/clang/test/CIR/CodeGen/new.cpp b/clang/test/CIR/CodeGen/new.cpp index 089617055ca0..ab972098ecc0 100644 --- a/clang/test/CIR/CodeGen/new.cpp +++ b/clang/test/CIR/CodeGen/new.cpp @@ -14,19 +14,19 @@ void m(int a, int b) { // CHECK: cir.func linkonce_odr @_ZSt11make_sharedI1SJRiS1_EESt10shared_ptrIT_EDpOT0_( // CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["args", init] {alignment = 8 : i64} // CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["args", init] {alignment = 8 : i64} -// CHECK: %2 = cir.alloca !ty_22class2Estd3A3Ashared_ptr22, cir.ptr , ["__retval"] {alignment = 1 : i64} +// CHECK: %2 = cir.alloca !ty_22std3A3Ashared_ptr22, cir.ptr , ["__retval"] {alignment = 1 : i64} // CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK: cir.store %arg1, %1 : !cir.ptr, cir.ptr > // CHECK: cir.scope { // CHECK: %4 = cir.const(#cir.int<1> : !u64i) : !u64i // CHECK: %5 = cir.call @_Znwm(%4) : (!u64i) -> !cir.ptr -// CHECK: %6 = cir.cast(bitcast, %5 : !cir.ptr), !cir.ptr +// CHECK: %6 = cir.cast(bitcast, %5 : !cir.ptr), !cir.ptr // CHECK: %7 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK: %8 = cir.load %7 : cir.ptr , !s32i // CHECK: %9 = cir.load %1 : cir.ptr >, !cir.ptr // CHECK: %10 = cir.load %9 : cir.ptr , !s32i -// CHECK: cir.call @_ZN1SC1Eii(%6, %8, %10) : (!cir.ptr, !s32i, !s32i) -> () -// CHECK: cir.call @_ZNSt10shared_ptrI1SEC1EPS0_(%2, %6) : (!cir.ptr, !cir.ptr) -> () +// CHECK: cir.call @_ZN1SC1Eii(%6, %8, %10) : (!cir.ptr, !s32i, !s32i) -> () +// CHECK: cir.call @_ZNSt10shared_ptrI1SEC1EPS0_(%2, %6) : (!cir.ptr, !cir.ptr) -> () // CHECK: } class B { @@ -36,19 +36,19 @@ class B { } }; -// CHECK: cir.func linkonce_odr @_ZN1B9constructEPS_(%arg0: !cir.ptr -// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} -// CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["__p", init] {alignment = 8 : i64} -// CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > -// CHECK: cir.store %arg1, %1 : !cir.ptr, cir.ptr > -// CHECK: %2 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK: cir.func linkonce_odr @_ZN1B9constructEPS_(%arg0: !cir.ptr +// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["__p", init] {alignment = 8 : i64} +// CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK: cir.store %arg1, %1 : !cir.ptr, cir.ptr > +// CHECK: %2 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK: %3 = cir.const(#cir.int<1> : !u64i) : !u64i -// CHECK: %4 = cir.load %1 : cir.ptr >, !cir.ptr -// CHECK: %5 = cir.cast(bitcast, %4 : !cir.ptr), !cir.ptr -// CHECK: %6 = cir.cast(bitcast, %5 : !cir.ptr), !cir.ptr +// CHECK: %4 = cir.load %1 : cir.ptr >, !cir.ptr +// CHECK: %5 = cir.cast(bitcast, %4 : !cir.ptr), !cir.ptr +// CHECK: %6 = cir.cast(bitcast, %5 : !cir.ptr), !cir.ptr // cir.call @B::B()(%new_placament_ptr) -// CHECK: cir.call @_ZN1BC1Ev(%6) : (!cir.ptr) -> () +// CHECK: cir.call @_ZN1BC1Ev(%6) : (!cir.ptr) -> () // CHECK: cir.return // CHECK: } diff --git a/clang/test/CIR/CodeGen/nrvo.cpp b/clang/test/CIR/CodeGen/nrvo.cpp index 37fa8cfc416b..894690bd7c0d 100644 --- a/clang/test/CIR/CodeGen/nrvo.cpp +++ b/clang/test/CIR/CodeGen/nrvo.cpp @@ -9,23 +9,23 @@ std::vector test_nrvo() { return result; } -// CHECK: !ty_22class2Estd3A3Avector22 = !cir.struct<"class.std::vector" {!cir.ptr>, !cir.ptr>, !cir.ptr>}> +// CHECK: !ty_22std3A3Avector22 = !cir.struct>, !cir.ptr>, !cir.ptr>}> -// CHECK: cir.func @_Z9test_nrvov() -> !ty_22class2Estd3A3Avector22 -// CHECK: %0 = cir.alloca !ty_22class2Estd3A3Avector22, cir.ptr , ["__retval", init] {alignment = 8 : i64} +// CHECK: cir.func @_Z9test_nrvov() -> !ty_22std3A3Avector22 +// CHECK: %0 = cir.alloca !ty_22std3A3Avector22, cir.ptr , ["__retval", init] {alignment = 8 : i64} // CHECK: %1 = cir.alloca !cir.bool, cir.ptr , ["nrvo"] {alignment = 1 : i64} // CHECK: %2 = cir.const(#false) : !cir.bool // CHECK: cir.store %2, %1 : !cir.bool, cir.ptr -// CHECK: cir.call @_ZNSt6vectorIPKcEC1Ev(%0) : (!cir.ptr) -> () +// CHECK: cir.call @_ZNSt6vectorIPKcEC1Ev(%0) : (!cir.ptr) -> () // CHECK: cir.scope { // CHECK: %5 = cir.alloca !cir.ptr, cir.ptr >, ["ref.tmp0"] {alignment = 8 : i64} // CHECK: %6 = cir.get_global @".str" : cir.ptr > // CHECK: %7 = cir.cast(array_to_ptrdecay, %6 : !cir.ptr>), !cir.ptr // CHECK: cir.store %7, %5 : !cir.ptr, cir.ptr > -// CHECK: cir.call @_ZNSt6vectorIPKcE9push_backEOS1_(%0, %5) : (!cir.ptr, !cir.ptr>) -> () +// CHECK: cir.call @_ZNSt6vectorIPKcE9push_backEOS1_(%0, %5) : (!cir.ptr, !cir.ptr>) -> () // CHECK: } // CHECK: %3 = cir.const(#true) : !cir.bool // CHECK: cir.store %3, %1 : !cir.bool, cir.ptr -// CHECK: %4 = cir.load %0 : cir.ptr , !ty_22class2Estd3A3Avector22 -// CHECK: cir.return %4 : !ty_22class2Estd3A3Avector22 +// CHECK: %4 = cir.load %0 : cir.ptr , !ty_22std3A3Avector22 +// CHECK: cir.return %4 : !ty_22std3A3Avector22 // CHECK: } diff --git a/clang/test/CIR/CodeGen/rangefor.cpp b/clang/test/CIR/CodeGen/rangefor.cpp index e4e1f0281886..8f9ab9fdb860 100644 --- a/clang/test/CIR/CodeGen/rangefor.cpp +++ b/clang/test/CIR/CodeGen/rangefor.cpp @@ -21,53 +21,53 @@ void init(unsigned numImages) { } } -// CHECK: !ty_22struct2Etriple22 = !cir.struct<"struct.triple" {!u32i, !cir.ptr, !u32i}> -// CHECK: !ty_22class2Estd3A3Avector22 = !cir.struct<"class.std::vector" {!cir.ptr, !cir.ptr, !cir.ptr}> -// CHECK: !ty_22struct2E__vector_iterator22 = !cir.struct<"struct.__vector_iterator" {!cir.ptr}> +// CHECK-DAG: !ty_22triple22 = !cir.struct, !u32i}> +// CHECK-DAG: !ty_22std3A3Avector22 = !cir.struct, !cir.ptr, !cir.ptr}> +// CHECK-DAG: !ty_22__vector_iterator22 = !cir.struct}> // CHECK: cir.func @_Z4initj(%arg0: !u32i // CHECK: %0 = cir.alloca !u32i, cir.ptr , ["numImages", init] {alignment = 4 : i64} -// CHECK: %1 = cir.alloca !ty_22class2Estd3A3Avector22, cir.ptr , ["images", init] {alignment = 8 : i64} +// CHECK: %1 = cir.alloca !ty_22std3A3Avector22, cir.ptr , ["images", init] {alignment = 8 : i64} // CHECK: cir.store %arg0, %0 : !u32i, cir.ptr // CHECK: %2 = cir.load %0 : cir.ptr , !u32i // CHECK: %3 = cir.cast(integral, %2 : !u32i), !u64i -// CHECK: cir.call @_ZNSt6vectorI6tripleEC1Em(%1, %3) : (!cir.ptr, !u64i) -> () +// CHECK: cir.call @_ZNSt6vectorI6tripleEC1Em(%1, %3) : (!cir.ptr, !u64i) -> () // CHECK: cir.scope { -// CHECK: %4 = cir.alloca !cir.ptr, cir.ptr >, ["__range1", init] {alignment = 8 : i64} -// CHECK: %5 = cir.alloca !ty_22struct2E__vector_iterator22, cir.ptr , ["__begin1", init] {alignment = 8 : i64} -// CHECK: %6 = cir.alloca !ty_22struct2E__vector_iterator22, cir.ptr , ["__end1", init] {alignment = 8 : i64} -// CHECK: %7 = cir.alloca !cir.ptr, cir.ptr >, ["image", init] {alignment = 8 : i64} -// CHECK: cir.store %1, %4 : !cir.ptr, cir.ptr > -// CHECK: %8 = cir.load %4 : cir.ptr >, !cir.ptr -// CHECK: %9 = cir.call @_ZNSt6vectorI6tripleE5beginEv(%8) : (!cir.ptr) -> !ty_22struct2E__vector_iterator22 -// CHECK: cir.store %9, %5 : !ty_22struct2E__vector_iterator22, cir.ptr -// CHECK: %10 = cir.load %4 : cir.ptr >, !cir.ptr -// CHECK: %11 = cir.call @_ZNSt6vectorI6tripleE3endEv(%10) : (!cir.ptr) -> !ty_22struct2E__vector_iterator22 -// CHECK: cir.store %11, %6 : !ty_22struct2E__vector_iterator22, cir.ptr +// CHECK: %4 = cir.alloca !cir.ptr, cir.ptr >, ["__range1", init] {alignment = 8 : i64} +// CHECK: %5 = cir.alloca !ty_22__vector_iterator22, cir.ptr , ["__begin1", init] {alignment = 8 : i64} +// CHECK: %6 = cir.alloca !ty_22__vector_iterator22, cir.ptr , ["__end1", init] {alignment = 8 : i64} +// CHECK: %7 = cir.alloca !cir.ptr, cir.ptr >, ["image", init] {alignment = 8 : i64} +// CHECK: cir.store %1, %4 : !cir.ptr, cir.ptr > +// CHECK: %8 = cir.load %4 : cir.ptr >, !cir.ptr +// CHECK: %9 = cir.call @_ZNSt6vectorI6tripleE5beginEv(%8) : (!cir.ptr) -> !ty_22__vector_iterator22 +// CHECK: cir.store %9, %5 : !ty_22__vector_iterator22, cir.ptr +// CHECK: %10 = cir.load %4 : cir.ptr >, !cir.ptr +// CHECK: %11 = cir.call @_ZNSt6vectorI6tripleE3endEv(%10) : (!cir.ptr) -> !ty_22__vector_iterator22 +// CHECK: cir.store %11, %6 : !ty_22__vector_iterator22, cir.ptr // CHECK: cir.loop for(cond : { -// CHECK: %12 = cir.call @_ZNK17__vector_iteratorI6triplePS0_RS0_EneERKS3_(%5, %6) : (!cir.ptr, !cir.ptr) -> !cir.bool +// CHECK: %12 = cir.call @_ZNK17__vector_iteratorI6triplePS0_RS0_EneERKS3_(%5, %6) : (!cir.ptr, !cir.ptr) -> !cir.bool // CHECK: cir.brcond %12 ^bb1, ^bb2 // CHECK: ^bb1: // pred: ^bb0 // CHECK: cir.yield continue // CHECK: ^bb2: // pred: ^bb0 // CHECK: cir.yield // CHECK: }, step : { -// CHECK: %12 = cir.call @_ZN17__vector_iteratorI6triplePS0_RS0_EppEv(%5) : (!cir.ptr) -> !cir.ptr +// CHECK: %12 = cir.call @_ZN17__vector_iteratorI6triplePS0_RS0_EppEv(%5) : (!cir.ptr) -> !cir.ptr // CHECK: cir.yield // CHECK: }) { -// CHECK: %12 = cir.call @_ZNK17__vector_iteratorI6triplePS0_RS0_EdeEv(%5) : (!cir.ptr) -> !cir.ptr -// CHECK: cir.store %12, %7 : !cir.ptr, cir.ptr > +// CHECK: %12 = cir.call @_ZNK17__vector_iteratorI6triplePS0_RS0_EdeEv(%5) : (!cir.ptr) -> !cir.ptr +// CHECK: cir.store %12, %7 : !cir.ptr, cir.ptr > // CHECK: cir.scope { -// CHECK: %13 = cir.alloca !ty_22struct2Etriple22, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} -// CHECK: %14 = cir.const(#cir.zero : !ty_22struct2Etriple22) : !ty_22struct2Etriple22 -// CHECK: cir.store %14, %13 : !ty_22struct2Etriple22, cir.ptr -// CHECK: %15 = "cir.struct_element_addr"(%13) <{member_index = 0 : index, member_name = "type"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %13 = cir.alloca !ty_22triple22, cir.ptr , ["ref.tmp0"] {alignment = 8 : i64} +// CHECK: %14 = cir.const(#cir.zero : !ty_22triple22) : !ty_22triple22 +// CHECK: cir.store %14, %13 : !ty_22triple22, cir.ptr +// CHECK: %15 = "cir.struct_element_addr"(%13) <{member_index = 0 : index, member_name = "type"}> : (!cir.ptr) -> !cir.ptr // CHECK: %16 = cir.const(#cir.int<1000024002> : !u32i) : !u32i // CHECK: cir.store %16, %15 : !u32i, cir.ptr -// CHECK: %17 = "cir.struct_element_addr"(%13) <{member_index = 1 : index, member_name = "next"}> : (!cir.ptr) -> !cir.ptr> -// CHECK: %18 = "cir.struct_element_addr"(%13) <{member_index = 2 : index, member_name = "image"}> : (!cir.ptr) -> !cir.ptr -// CHECK: %19 = cir.load %7 : cir.ptr >, !cir.ptr -// CHECK: %20 = cir.call @_ZN6tripleaSEOS_(%19, %13) : (!cir.ptr, !cir.ptr) -> !cir.ptr +// CHECK: %17 = "cir.struct_element_addr"(%13) <{member_index = 1 : index, member_name = "next"}> : (!cir.ptr) -> !cir.ptr> +// CHECK: %18 = "cir.struct_element_addr"(%13) <{member_index = 2 : index, member_name = "image"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %19 = cir.load %7 : cir.ptr >, !cir.ptr +// CHECK: %20 = cir.call @_ZN6tripleaSEOS_(%19, %13) : (!cir.ptr, !cir.ptr) -> !cir.ptr // CHECK: } // CHECK: cir.yield // CHECK: } diff --git a/clang/test/CIR/CodeGen/skip-functions-from-system-headers.cpp b/clang/test/CIR/CodeGen/skip-functions-from-system-headers.cpp index a7c4e9059ffe..5f7f4cd29400 100644 --- a/clang/test/CIR/CodeGen/skip-functions-from-system-headers.cpp +++ b/clang/test/CIR/CodeGen/skip-functions-from-system-headers.cpp @@ -15,4 +15,4 @@ void test() { // CHECK-NOT: cir.func linkonce_odr @_ZN6StringC1EPKc // CHECK: cir.func @_Z4testv() -// CHECK: cir.call @_ZN6StringC1Ev(%0) : (!cir.ptr) -> () \ No newline at end of file +// CHECK: cir.call @_ZN6StringC1Ev(%0) : (!cir.ptr) -> () \ No newline at end of file diff --git a/clang/test/CIR/CodeGen/static.cpp b/clang/test/CIR/CodeGen/static.cpp index 2b434f3fff5c..1dcb798a6a7e 100644 --- a/clang/test/CIR/CodeGen/static.cpp +++ b/clang/test/CIR/CodeGen/static.cpp @@ -17,33 +17,33 @@ static Init __ioinit(true); static Init __ioinit2(false); // BEFORE: module {{.*}} { -// BEFORE-NEXT: cir.func private @_ZN4InitC1Eb(!cir.ptr, !cir.bool) -// BEFORE-NEXT: cir.global "private" internal @_ZL8__ioinit = ctor : !ty_22class2EInit22 { -// BEFORE-NEXT: %0 = cir.get_global @_ZL8__ioinit : cir.ptr +// BEFORE-NEXT: cir.func private @_ZN4InitC1Eb(!cir.ptr, !cir.bool) +// BEFORE-NEXT: cir.global "private" internal @_ZL8__ioinit = ctor : !ty_22Init22 { +// BEFORE-NEXT: %0 = cir.get_global @_ZL8__ioinit : cir.ptr // BEFORE-NEXT: %1 = cir.const(#true) : !cir.bool -// BEFORE-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () +// BEFORE-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () // BEFORE-NEXT: } {ast = #cir.vardecl.ast} -// BEFORE: cir.global "private" internal @_ZL9__ioinit2 = ctor : !ty_22class2EInit22 { -// BEFORE-NEXT: %0 = cir.get_global @_ZL9__ioinit2 : cir.ptr +// BEFORE: cir.global "private" internal @_ZL9__ioinit2 = ctor : !ty_22Init22 { +// BEFORE-NEXT: %0 = cir.get_global @_ZL9__ioinit2 : cir.ptr // BEFORE-NEXT: %1 = cir.const(#false) : !cir.bool -// BEFORE-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () +// BEFORE-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () // BEFORE-NEXT: } {ast = #cir.vardecl.ast} // BEFORE-NEXT: } // AFTER: module {{.*}} attributes {{.*}}cir.globalCtors = [#cir.globalCtor<"__cxx_global_var_init">, #cir.globalCtor<"__cxx_global_var_init.1">] -// AFTER-NEXT: cir.func private @_ZN4InitC1Eb(!cir.ptr, !cir.bool) -// AFTER-NEXT: cir.global "private" internal @_ZL8__ioinit = #cir.zero : !ty_22class2EInit22 {ast = #cir.vardecl.ast} +// AFTER-NEXT: cir.func private @_ZN4InitC1Eb(!cir.ptr, !cir.bool) +// AFTER-NEXT: cir.global "private" internal @_ZL8__ioinit = #cir.zero : !ty_22Init22 {ast = #cir.vardecl.ast} // AFTER-NEXT: cir.func internal private @__cxx_global_var_init() -// AFTER-NEXT: %0 = cir.get_global @_ZL8__ioinit : cir.ptr +// AFTER-NEXT: %0 = cir.get_global @_ZL8__ioinit : cir.ptr // AFTER-NEXT: %1 = cir.const(#true) : !cir.bool -// AFTER-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () +// AFTER-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () // AFTER-NEXT: cir.return -// AFTER: cir.global "private" internal @_ZL9__ioinit2 = #cir.zero : !ty_22class2EInit22 {ast = #cir.vardecl.ast} +// AFTER: cir.global "private" internal @_ZL9__ioinit2 = #cir.zero : !ty_22Init22 {ast = #cir.vardecl.ast} // AFTER-NEXT: cir.func internal private @__cxx_global_var_init.1() -// AFTER-NEXT: %0 = cir.get_global @_ZL9__ioinit2 : cir.ptr +// AFTER-NEXT: %0 = cir.get_global @_ZL9__ioinit2 : cir.ptr // AFTER-NEXT: %1 = cir.const(#false) : !cir.bool -// AFTER-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () +// AFTER-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !cir.bool) -> () // AFTER-NEXT: cir.return // AFTER: cir.func private @_GLOBAL__sub_I_static.cpp() // AFTER-NEXT: cir.call @__cxx_global_var_init() : () -> () diff --git a/clang/test/CIR/CodeGen/struct.c b/clang/test/CIR/CodeGen/struct.c index dcaf5dd5f308..c1d9a73fd454 100644 --- a/clang/test/CIR/CodeGen/struct.c +++ b/clang/test/CIR/CodeGen/struct.c @@ -17,28 +17,28 @@ void baz(void) { struct Foo f; } -// CHECK-DAG: !ty_22struct2EBar22 = !cir.struct<"struct.Bar" {!s32i, !s8i}> -// CHECK-DAG: !ty_22struct2EFoo22 = !cir.struct<"struct.Foo" {!s32i, !s8i, !ty_22struct2EBar22}> +// CHECK-DAG: !ty_22Bar22 = !cir.struct +// CHECK-DAG: !ty_22Foo22 = !cir.struct // CHECK-DAG: module {{.*}} { // CHECK: cir.func @baz() -// CHECK-NEXT: %0 = cir.alloca !ty_22struct2EBar22, cir.ptr , ["b"] {alignment = 4 : i64} -// CHECK-NEXT: %1 = cir.alloca !ty_22struct2EFoo22, cir.ptr , ["f"] {alignment = 4 : i64} +// CHECK-NEXT: %0 = cir.alloca !ty_22Bar22, cir.ptr , ["b"] {alignment = 4 : i64} +// CHECK-NEXT: %1 = cir.alloca !ty_22Foo22, cir.ptr , ["f"] {alignment = 4 : i64} // CHECK-NEXT: cir.return // CHECK-NEXT: } void shouldConstInitStructs(void) { // CHECK: cir.func @shouldConstInitStructs struct Foo f = {1, 2, {3, 4}}; - // CHECK: %[[#V0:]] = cir.alloca !ty_22struct2EFoo22, cir.ptr , ["f"] {alignment = 4 : i64} - // CHECK: %[[#V1:]] = cir.const(#cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s8i, #cir.const_struct<{#cir.int<3> : !s32i, #cir.int<4> : !s8i}> : !ty_22struct2EBar22}> : !ty_22struct2EFoo22) : !ty_22struct2EFoo22 - // CHECK: cir.store %[[#V1]], %[[#V0]] : !ty_22struct2EFoo22, cir.ptr + // CHECK: %[[#V0:]] = cir.alloca !ty_22Foo22, cir.ptr , ["f"] {alignment = 4 : i64} + // CHECK: %[[#V1:]] = cir.const(#cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s8i, #cir.const_struct<{#cir.int<3> : !s32i, #cir.int<4> : !s8i}> : !ty_22Bar22}> : !ty_22Foo22) : !ty_22Foo22 + // CHECK: cir.store %[[#V1]], %[[#V0]] : !ty_22Foo22, cir.ptr } // Should zero-initialize uninitialized global structs. struct S { int a,b; } s; -// CHECK-DAG: cir.global external @s = #cir.zero : !ty_22struct2ES22 +// CHECK-DAG: cir.global external @s = #cir.zero : !ty_22S22 // Should initialize basic global structs. struct S1 { @@ -46,7 +46,7 @@ struct S1 { float f; int *p; } s1 = {1, .1, 0}; -// CHECK-DAG: cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, 1.000000e-01 : f32, #cir.null : !cir.ptr}> : !ty_22struct2ES122 +// CHECK-DAG: cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, 1.000000e-01 : f32, #cir.null : !cir.ptr}> : !ty_22S122 // Should initialize global nested structs. struct S2 { @@ -54,19 +54,19 @@ struct S2 { int a; } s2a; } s2 = {{1}}; -// CHECK-DAG: cir.global external @s2 = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES2A22}> : !ty_22struct2ES222 +// CHECK-DAG: cir.global external @s2 = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S2A22}> : !ty_22S222 // Should initialize global arrays of structs. struct S3 { int a; } s3[3] = {{1}, {2}, {3}}; -// CHECK-DAG: cir.global external @s3 = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES322, #cir.const_struct<{#cir.int<2> : !s32i}> : !ty_22struct2ES322, #cir.const_struct<{#cir.int<3> : !s32i}> : !ty_22struct2ES322]> : !cir.array +// CHECK-DAG: cir.global external @s3 = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S322, #cir.const_struct<{#cir.int<2> : !s32i}> : !ty_22S322, #cir.const_struct<{#cir.int<3> : !s32i}> : !ty_22S322]> : !cir.array void shouldCopyStructAsCallArg(struct S1 s) { // CHECK-DAG: cir.func @shouldCopyStructAsCallArg shouldCopyStructAsCallArg(s); - // CHECK-DAG: %[[#LV:]] = cir.load %{{.+}} : cir.ptr , !ty_22struct2ES122 - // CHECK-DAG: cir.call @shouldCopyStructAsCallArg(%[[#LV]]) : (!ty_22struct2ES122) -> () + // CHECK-DAG: %[[#LV:]] = cir.load %{{.+}} : cir.ptr , !ty_22S122 + // CHECK-DAG: cir.call @shouldCopyStructAsCallArg(%[[#LV]]) : (!ty_22S122) -> () } struct Bar shouldGenerateAndAccessStructArrays(void) { @@ -75,6 +75,6 @@ struct Bar shouldGenerateAndAccessStructArrays(void) { } // CHECK-DAG: cir.func @shouldGenerateAndAccessStructArrays // CHECK-DAG: %[[#STRIDE:]] = cir.const(#cir.int<0> : !s32i) : !s32i -// CHECK-DAG: %[[#DARR:]] = cir.cast(array_to_ptrdecay, %{{.+}} : !cir.ptr>), !cir.ptr -// CHECK-DAG: %[[#ELT:]] = cir.ptr_stride(%[[#DARR]] : !cir.ptr, %[[#STRIDE]] : !s32i), !cir.ptr -// CHECK-DAG: cir.copy %[[#ELT]] to %{{.+}} : !cir.ptr +// CHECK-DAG: %[[#DARR:]] = cir.cast(array_to_ptrdecay, %{{.+}} : !cir.ptr>), !cir.ptr +// CHECK-DAG: %[[#ELT:]] = cir.ptr_stride(%[[#DARR]] : !cir.ptr, %[[#STRIDE]] : !s32i), !cir.ptr +// CHECK-DAG: cir.copy %[[#ELT]] to %{{.+}} : !cir.ptr diff --git a/clang/test/CIR/CodeGen/struct.cpp b/clang/test/CIR/CodeGen/struct.cpp index d3948bf4ccd8..160db00ed128 100644 --- a/clang/test/CIR/CodeGen/struct.cpp +++ b/clang/test/CIR/CodeGen/struct.cpp @@ -26,37 +26,37 @@ void baz() { struct incomplete; void yoyo(incomplete *i) {} -// CHECK: !ty_22struct2Eincomplete22 = !cir.struct<"struct.incomplete" incomplete -// CHECK: !ty_22struct2EBar22 = !cir.struct<"struct.Bar" {!s32i, !s8i}> - -// CHECK: !ty_22struct2EFoo22 = !cir.struct<"struct.Foo" {!s32i, !s8i, !ty_22struct2EBar22}> -// CHECK: !ty_22struct2EMandalore22 = !cir.struct<"struct.Mandalore" {!u32i, !cir.ptr, !s32i} #cir.recdecl.ast> -// CHECK: !ty_22class2EAdv22 = !cir.struct<"class.Adv" {!ty_22struct2EMandalore22}> -// CHECK: !ty_22struct2EEntry22 = !cir.struct<"struct.Entry" {!cir.ptr, !cir.ptr)>>}> - -// CHECK: cir.func linkonce_odr @_ZN3Bar6methodEv(%arg0: !cir.ptr -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > -// CHECK-NEXT: %1 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK-DAG-DAG: !ty_22incomplete22 = !cir.struct + +// CHECK-DAG: !ty_22Foo22 = !cir.struct +// CHECK-DAG: !ty_22Mandalore22 = !cir.struct, !s32i} #cir.recdecl.ast> +// CHECK-DAG: !ty_22Adv22 = !cir.struct +// CHECK-DAG: !ty_22Entry22 = !cir.struct, !cir.ptr)>>}> + +// CHECK: cir.func linkonce_odr @_ZN3Bar6methodEv(%arg0: !cir.ptr +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: %1 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK-NEXT: cir.return // CHECK-NEXT: } -// CHECK: cir.func linkonce_odr @_ZN3Bar7method2Ei(%arg0: !cir.ptr {{.*}}, %arg1: !s32i -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK: cir.func linkonce_odr @_ZN3Bar7method2Ei(%arg0: !cir.ptr {{.*}}, %arg1: !s32i +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} // CHECK-NEXT: %1 = cir.alloca !s32i, cir.ptr , ["a", init] {alignment = 4 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK-NEXT: cir.store %arg1, %1 : !s32i, cir.ptr -// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK-NEXT: %2 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK-NEXT: cir.return // CHECK-NEXT: } -// CHECK: cir.func linkonce_odr @_ZN3Bar7method3Ei(%arg0: !cir.ptr {{.*}}, %arg1: !s32i -// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK: cir.func linkonce_odr @_ZN3Bar7method3Ei(%arg0: !cir.ptr {{.*}}, %arg1: !s32i +// CHECK-NEXT: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} // CHECK-NEXT: %1 = cir.alloca !s32i, cir.ptr , ["a", init] {alignment = 4 : i64} // CHECK-NEXT: %2 = cir.alloca !s32i, cir.ptr , ["__retval"] {alignment = 4 : i64} -// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK-NEXT: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK-NEXT: cir.store %arg1, %1 : !s32i, cir.ptr -// CHECK-NEXT: %3 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK-NEXT: %3 = cir.load %0 : cir.ptr >, !cir.ptr // CHECK-NEXT: %4 = cir.load %1 : cir.ptr , !s32i // CHECK-NEXT: cir.store %4, %2 : !s32i, cir.ptr // CHECK-NEXT: %5 = cir.load %2 : cir.ptr , !s32i @@ -64,14 +64,14 @@ void yoyo(incomplete *i) {} // CHECK-NEXT: } // CHECK: cir.func @_Z3bazv() -// CHECK-NEXT: %0 = cir.alloca !ty_22struct2EBar22, cir.ptr , ["b"] {alignment = 4 : i64} +// CHECK-NEXT: %0 = cir.alloca !ty_22Bar22, cir.ptr , ["b"] {alignment = 4 : i64} // CHECK-NEXT: %1 = cir.alloca !s32i, cir.ptr , ["result", init] {alignment = 4 : i64} -// CHECK-NEXT: %2 = cir.alloca !ty_22struct2EFoo22, cir.ptr , ["f"] {alignment = 4 : i64} -// CHECK-NEXT: cir.call @_ZN3Bar6methodEv(%0) : (!cir.ptr) -> () +// CHECK-NEXT: %2 = cir.alloca !ty_22Foo22, cir.ptr , ["f"] {alignment = 4 : i64} +// CHECK-NEXT: cir.call @_ZN3Bar6methodEv(%0) : (!cir.ptr) -> () // CHECK-NEXT: %3 = cir.const(#cir.int<4> : !s32i) : !s32i -// CHECK-NEXT: cir.call @_ZN3Bar7method2Ei(%0, %3) : (!cir.ptr, !s32i) -> () +// CHECK-NEXT: cir.call @_ZN3Bar7method2Ei(%0, %3) : (!cir.ptr, !s32i) -> () // CHECK-NEXT: %4 = cir.const(#cir.int<4> : !s32i) : !s32i -// CHECK-NEXT: %5 = cir.call @_ZN3Bar7method3Ei(%0, %4) : (!cir.ptr, !s32i) -> !s32i +// CHECK-NEXT: %5 = cir.call @_ZN3Bar7method3Ei(%0, %4) : (!cir.ptr, !s32i) -> !s32i // CHECK-NEXT: cir.store %5, %1 : !s32i, cir.ptr // CHECK-NEXT: cir.return // CHECK-NEXT: } @@ -94,18 +94,18 @@ class Adv { void m() { Adv C; } -// CHECK: cir.func linkonce_odr @_ZN3AdvC2Ev(%arg0: !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.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "x"}> : (!cir.ptr) -> !cir.ptr -// CHECK: %3 = "cir.struct_element_addr"(%2) <{member_index = 0 : index, member_name = "w"}> : (!cir.ptr) -> !cir.ptr +// CHECK: cir.func linkonce_odr @_ZN3AdvC2Ev(%arg0: !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.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "x"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %3 = "cir.struct_element_addr"(%2) <{member_index = 0 : index, member_name = "w"}> : (!cir.ptr) -> !cir.ptr // CHECK: %4 = cir.const(#cir.int<1000024001> : !u32i) : !u32i // CHECK: cir.store %4, %3 : !u32i, cir.ptr -// CHECK: %5 = "cir.struct_element_addr"(%2) <{member_index = 1 : index, member_name = "n"}> : (!cir.ptr) -> !cir.ptr> +// CHECK: %5 = "cir.struct_element_addr"(%2) <{member_index = 1 : index, member_name = "n"}> : (!cir.ptr) -> !cir.ptr> // CHECK: %6 = cir.const(#cir.null : !cir.ptr) : !cir.ptr // CHECK: cir.store %6, %5 : !cir.ptr, cir.ptr > -// CHECK: %7 = "cir.struct_element_addr"(%2) <{member_index = 2 : index, member_name = "d"}> : (!cir.ptr) -> !cir.ptr +// CHECK: %7 = "cir.struct_element_addr"(%2) <{member_index = 2 : index, member_name = "d"}> : (!cir.ptr) -> !cir.ptr // CHECK: %8 = cir.const(#cir.int<0> : !s32i) : !s32i // CHECK: cir.store %8, %7 : !s32i, cir.ptr // CHECK: cir.return @@ -117,19 +117,19 @@ struct A { // Should globally const-initialize struct members. struct A simpleConstInit = {1}; -// CHECK: cir.global external @simpleConstInit = #cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2EA22 +// CHECK: cir.global external @simpleConstInit = #cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22A22 // Should globally const-initialize arrays with struct members. struct A arrConstInit[1] = {{1}}; -// CHECK: cir.global external @arrConstInit = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2EA22]> : !cir.array +// CHECK: cir.global external @arrConstInit = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22A22]> : !cir.array // Should locally copy struct members. void shouldLocallyCopyStructAssignments(void) { struct A a = { 3 }; - // CHECK: %[[#SA:]] = cir.alloca !ty_22struct2EA22, cir.ptr , ["a"] {alignment = 4 : i64} + // CHECK: %[[#SA:]] = cir.alloca !ty_22A22, cir.ptr , ["a"] {alignment = 4 : i64} struct A b = a; - // CHECK: %[[#SB:]] = cir.alloca !ty_22struct2EA22, cir.ptr , ["b", init] {alignment = 4 : i64} - // cir.copy %[[#SA]] to %[[SB]] : !cir.ptr + // CHECK: %[[#SB:]] = cir.alloca !ty_22A22, cir.ptr , ["b", init] {alignment = 4 : i64} + // cir.copy %[[#SA]] to %[[SB]] : !cir.ptr } A get_default() { return A{2}; } @@ -141,12 +141,12 @@ struct S { void h() { S s; } // CHECK: cir.func @_Z1hv() -// CHECK: %0 = cir.alloca !ty_22struct2ES22, cir.ptr , ["s", init] {alignment = 1 : i64} -// CHECK: %1 = cir.alloca !ty_22struct2EA22, cir.ptr , ["agg.tmp0"] {alignment = 4 : i64} -// CHECK: %2 = cir.call @_Z11get_defaultv() : () -> !ty_22struct2EA22 -// CHECK: cir.store %2, %1 : !ty_22struct2EA22, cir.ptr -// CHECK: %3 = cir.load %1 : cir.ptr , !ty_22struct2EA22 -// CHECK: cir.call @_ZN1SC1E1A(%0, %3) : (!cir.ptr, !ty_22struct2EA22) -> () +// CHECK: %0 = cir.alloca !ty_22S22, cir.ptr , ["s", init] {alignment = 1 : i64} +// CHECK: %1 = cir.alloca !ty_22A22, cir.ptr , ["agg.tmp0"] {alignment = 4 : i64} +// CHECK: %2 = cir.call @_Z11get_defaultv() : () -> !ty_22A22 +// CHECK: cir.store %2, %1 : !ty_22A22, cir.ptr +// CHECK: %3 = cir.load %1 : cir.ptr , !ty_22A22 +// CHECK: cir.call @_ZN1SC1E1A(%0, %3) : (!cir.ptr, !ty_22A22) -> () // CHECK: cir.return // CHECK: } @@ -162,6 +162,6 @@ struct Entry { void ppp() { Entry x; } -// CHECK: cir.func linkonce_odr @_ZN5EntryC2Ev(%arg0: !cir.ptr +// CHECK: cir.func linkonce_odr @_ZN5EntryC2Ev(%arg0: !cir.ptr -// CHECK: = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "procAddr"}> : (!cir.ptr) -> !cir.ptr, !cir.ptr)>>> +// CHECK: = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "procAddr"}> : (!cir.ptr) -> !cir.ptr, !cir.ptr)>>> diff --git a/clang/test/CIR/CodeGen/union.cpp b/clang/test/CIR/CodeGen/union.cpp index b93af75baccd..fe08b26e6677 100644 --- a/clang/test/CIR/CodeGen/union.cpp +++ b/clang/test/CIR/CodeGen/union.cpp @@ -12,14 +12,14 @@ void m() { yolm3 q3; } -// CHECK: !ty_22struct2Eanon22 = !cir.struct<"struct.anon" {!cir.bool, !s32i} #cir.recdecl.ast> -// CHECK: !ty_22struct2Eyolo22 = !cir.struct<"struct.yolo" {!s32i} #cir.recdecl.ast> -// CHECK: !ty_22struct2Eanon221 = !cir.struct<"struct.anon" {!cir.ptr, !s32i} #cir.recdecl.ast> +// CHECK: !ty_22anon22 = !cir.struct +// CHECK: !ty_22yolo22 = !cir.struct +// CHECK: !ty_22anon221 = !cir.struct, !s32i} #cir.recdecl.ast> -// CHECK: !ty_22union2Eyolm22 = !cir.struct<"union.yolm" {!ty_22struct2Eyolo22}> -// CHECK: !ty_22union2Eyolm222 = !cir.struct<"union.yolm2" {!ty_22struct2Eanon221}> +// CHECK: !ty_22yolm22 = !cir.struct +// CHECK: !ty_22yolm222 = !cir.struct // CHECK: cir.func @_Z1mv() -// CHECK: cir.alloca !ty_22union2Eyolm22, cir.ptr , ["q"] {alignment = 4 : i64} -// CHECK: cir.alloca !ty_22union2Eyolm222, cir.ptr , ["q2"] {alignment = 8 : i64} -// CHECK: cir.alloca !ty_22union2Eyolm322, cir.ptr , ["q3"] {alignment = 4 : i64} +// CHECK: cir.alloca !ty_22yolm22, cir.ptr , ["q"] {alignment = 4 : i64} +// CHECK: cir.alloca !ty_22yolm222, cir.ptr , ["q2"] {alignment = 8 : i64} +// CHECK: cir.alloca !ty_22yolm322, cir.ptr , ["q3"] {alignment = 4 : i64} diff --git a/clang/test/CIR/CodeGen/variadics.c b/clang/test/CIR/CodeGen/variadics.c index 529a340941a3..79e3b7b41f68 100644 --- a/clang/test/CIR/CodeGen/variadics.c +++ b/clang/test/CIR/CodeGen/variadics.c @@ -12,7 +12,7 @@ typedef __builtin_va_list va_list; #define va_arg(ap, type) __builtin_va_arg(ap, type) #define va_copy(dst, src) __builtin_va_copy(dst, src) -// CHECK: [[VALISTTYPE:!.+va_list.*]] = !cir.struct<"struct{{.*}}__va_list +// CHECK: [[VALISTTYPE:!.+va_list.*]] = !cir.struct !s32i diff --git a/clang/test/CIR/CodeGen/vector.cpp b/clang/test/CIR/CodeGen/vector.cpp index 23906b7af90d..d1652e6d75a0 100644 --- a/clang/test/CIR/CodeGen/vector.cpp +++ b/clang/test/CIR/CodeGen/vector.cpp @@ -12,13 +12,13 @@ namespace std { } // namespace std // CHECK: cir.func linkonce_odr @_ZNSt6vectorIyE6resizeEm( -// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} +// CHECK: %0 = cir.alloca !cir.ptr, cir.ptr >, ["this", init] {alignment = 8 : i64} // CHECK: %1 = cir.alloca !u64i, cir.ptr , ["__sz", init] {alignment = 8 : i64} // CHECK: %2 = cir.alloca !u64i, cir.ptr , ["__cs", init] {alignment = 8 : i64} -// CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > +// CHECK: cir.store %arg0, %0 : !cir.ptr, cir.ptr > // CHECK: cir.store %arg1, %1 : !u64i, cir.ptr -// CHECK: %3 = cir.load %0 : cir.ptr >, !cir.ptr -// CHECK: %4 = cir.call @_ZNKSt6vectorIyE4sizeEv(%3) : (!cir.ptr) -> !u64i +// CHECK: %3 = cir.load %0 : cir.ptr >, !cir.ptr +// CHECK: %4 = cir.call @_ZNKSt6vectorIyE4sizeEv(%3) : (!cir.ptr) -> !u64i // CHECK: cir.store %4, %2 : !u64i, cir.ptr // CHECK: cir.scope { // CHECK: %5 = cir.load %2 : cir.ptr , !u64i diff --git a/clang/test/CIR/CodeGen/vtable-rtti.cpp b/clang/test/CIR/CodeGen/vtable-rtti.cpp index e128b55b143c..6c2c510dd1bd 100644 --- a/clang/test/CIR/CodeGen/vtable-rtti.cpp +++ b/clang/test/CIR/CodeGen/vtable-rtti.cpp @@ -18,16 +18,16 @@ class B : public A }; // Type info B. -// CHECK: ![[TypeInfoB:ty_.*]] = !cir.struct<"" {!cir.ptr, !cir.ptr, !cir.ptr}> +// CHECK: ![[TypeInfoB:ty_.*]] = !cir.struct, !cir.ptr, !cir.ptr}> // vtable for A type -// CHECK: ![[VTableTypeA:ty_.*]] = !cir.struct<"" {!cir.array x 5>}> +// CHECK: ![[VTableTypeA:ty_.*]] = !cir.struct x 5>}> // Class A -// CHECK: ![[ClassA:ty_.*]] = !cir.struct<"class.A" {!cir.ptr>>} #cir.recdecl.ast> +// CHECK: ![[ClassA:ty_.*]] = !cir.struct>>} #cir.recdecl.ast> // Class B -// CHECK: ![[ClassB:ty_.*]] = !cir.struct<"class.B" {![[ClassA]]}> +// CHECK: ![[ClassB:ty_.*]] = !cir.struct // B ctor => @B::B() // Calls @A::A() and initialize __vptr with address of B's vtable. diff --git a/clang/test/CIR/IR/global.cir b/clang/test/CIR/IR/global.cir index d860f2632d25..378fdd4ba85b 100644 --- a/clang/test/CIR/IR/global.cir +++ b/clang/test/CIR/IR/global.cir @@ -3,12 +3,12 @@ !s8i = !cir.int !s32i = !cir.int !s64i = !cir.int -!ty_22class2EInit22 = !cir.struct<"class.Init" {!s8i} #cir.recdecl.ast> +!ty_22Init22 = !cir.struct module { cir.global external @a = #cir.int<3> : !s32i cir.global external @rgb = #cir.const_array<[#cir.int<0> : !s8i, #cir.int<-23> : !s8i, #cir.int<33> : !s8i] : !cir.array> cir.global external @b = #cir.const_array<"example\00" : !cir.array> - cir.global external @rgb2 = #cir.const_struct<{#cir.int<0> : !s8i, #cir.int<5> : !s64i, #cir.null : !cir.ptr}> : !cir.struct<"" {!s8i, !s64i, !cir.ptr}> + cir.global external @rgb2 = #cir.const_struct<{#cir.int<0> : !s8i, #cir.int<5> : !s64i, #cir.null : !cir.ptr}> : !cir.struct}> cir.global "private" constant internal @".str" : !cir.array {alignment = 1 : i64} cir.global "private" internal @c : !s32i cir.global "private" constant internal @".str2" = #cir.const_array<"example\00" : !cir.array> : !cir.array {alignment = 1 : i64} @@ -31,12 +31,12 @@ module { #cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2]> : !cir.ptr, #cir.global_view<@type_info_name_B> : !cir.ptr, #cir.global_view<@type_info_A> : !cir.ptr}> - : !cir.struct<"" {!cir.ptr, !cir.ptr, !cir.ptr}> - cir.func private @_ZN4InitC1Eb(!cir.ptr, !s8i) - cir.global "private" internal @_ZL8__ioinit = ctor : !ty_22class2EInit22 { - %0 = cir.get_global @_ZL8__ioinit : cir.ptr + : !cir.struct, !cir.ptr, !cir.ptr}> + cir.func private @_ZN4InitC1Eb(!cir.ptr, !s8i) + cir.global "private" internal @_ZL8__ioinit = ctor : !ty_22Init22 { + %0 = cir.get_global @_ZL8__ioinit : cir.ptr %1 = cir.const(#cir.int<3> : !s8i) : !s8i - cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !s8i) -> () + cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !s8i) -> () } } @@ -51,8 +51,8 @@ module { // CHECK: cir.func @use_global() // CHECK-NEXT: %0 = cir.get_global @a : cir.ptr -// CHECK: cir.global "private" internal @_ZL8__ioinit = ctor : !ty_22class2EInit22 { -// CHECK-NEXT: %0 = cir.get_global @_ZL8__ioinit : cir.ptr +// CHECK: cir.global "private" internal @_ZL8__ioinit = ctor : !ty_22Init22 { +// CHECK-NEXT: %0 = cir.get_global @_ZL8__ioinit : cir.ptr // CHECK-NEXT: %1 = cir.const(#cir.int<3> : !s8i) : !s8i -// CHECK-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !s8i) -> () +// CHECK-NEXT: cir.call @_ZN4InitC1Eb(%0, %1) : (!cir.ptr, !s8i) -> () // CHECK-NEXT: } diff --git a/clang/test/CIR/IR/invalid.cir b/clang/test/CIR/IR/invalid.cir index fc8d80128375..5c6e652e1f56 100644 --- a/clang/test/CIR/IR/invalid.cir +++ b/clang/test/CIR/IR/invalid.cir @@ -309,7 +309,7 @@ module { cir.global external @type_info_B = #cir.typeinfo<{ // expected-error {{element at index 0 has type '!cir.ptr>' but return type for this element is '!cir.ptr>'}} #cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2]> : !cir.ptr}> - : !cir.struct<"" {!cir.ptr}> + : !cir.struct}> } // expected-error {{'cir.global' expected constant attribute to match type}} // ----- diff --git a/clang/test/CIR/IR/struct.cir b/clang/test/CIR/IR/struct.cir index 4f98102a3bad..aa0acce60abd 100644 --- a/clang/test/CIR/IR/struct.cir +++ b/clang/test/CIR/IR/struct.cir @@ -1,21 +1,22 @@ -// RUN: cir-opt %s | cir-opt | FileCheck %s +// RUN: cir-opt %s -o %t.cir +// RUN: FileCheck --input-file=%t.cir %s !u8i = !cir.int !u16i = !cir.int !s32i = !cir.int !u32i = !cir.int -!ty_2222 = !cir.struct<"" {!cir.array x 5>}> -!ty_22221 = !cir.struct<"" {!cir.ptr, !cir.ptr, !cir.ptr}> -!ty_22class2EA22 = !cir.struct<"class.A" incomplete #cir.recdecl.ast> -// CHECK: !ty_22i22 = !cir.struct<"i" incomplete> -// CHECK: !ty_22S22 = !cir.struct<"S" {!u8i, !u16i, !u32i}> -!ty_22struct2ES22 = !cir.struct<"struct.S" {!s32i, !s32i}> +!ty_2222 = !cir.struct x 5>}> +!ty_22221 = !cir.struct, !cir.ptr, !cir.ptr}> +!ty_22A22 = !cir.struct +!ty_22i22 = !cir.struct +!ty_22S22 = !cir.struct +!ty_22S122 = !cir.struct module { cir.func @structs() { - %0 = cir.alloca !cir.ptr>, cir.ptr >>, ["s", init] - %1 = cir.alloca !cir.ptr>, cir.ptr >>, ["i", init] + %0 = cir.alloca !cir.ptr>, cir.ptr >>, ["s", init] + %1 = cir.alloca !cir.ptr>, cir.ptr >>, ["i", init] cir.return } @@ -24,8 +25,8 @@ module { // CHECK: %1 = cir.alloca !cir.ptr, cir.ptr >, ["i", init] cir.func @shouldSuccessfullyParseConstStructAttrs() { - %0 = cir.const(#cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_22struct2ES22) : !ty_22struct2ES22 - // CHECK: cir.const(#cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_22struct2ES22) : !ty_22struct2ES22 + %0 = cir.const(#cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_22S122) : !ty_22S122 + // CHECK: cir.const(#cir.const_struct<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !ty_22S122) : !ty_22S122 cir.return } } diff --git a/clang/test/CIR/IR/vtableAttr.cir b/clang/test/CIR/IR/vtableAttr.cir index 596644d2cfc7..ae175d5fa987 100644 --- a/clang/test/CIR/IR/vtableAttr.cir +++ b/clang/test/CIR/IR/vtableAttr.cir @@ -1,7 +1,7 @@ // RUN: cir-opt %s | FileCheck %s !u8i = !cir.int -!ty_2222 = !cir.struct<"" {!cir.array x 1>}> +!ty_2222 = !cir.struct x 1>}> module { // Should parse VTable attribute. cir.global external @testVTable = #cir.vtable<{#cir.const_array<[#cir.null : !cir.ptr]> : !cir.array x 1>}> : !ty_2222 diff --git a/clang/test/CIR/Lowering/array.cir b/clang/test/CIR/Lowering/array.cir index 3b85567acd91..1136f8a3beb5 100644 --- a/clang/test/CIR/Lowering/array.cir +++ b/clang/test/CIR/Lowering/array.cir @@ -2,7 +2,7 @@ // RUN: cir-translate %s -cir-to-llvmir -o - | FileCheck %s -check-prefix=LLVM !s32i = !cir.int -!ty_22struct2ES22 = !cir.struct<"struct.S" {!s32i} #cir.recdecl.ast> +!ty_22S22 = !cir.struct module { cir.func @foo() { @@ -21,7 +21,7 @@ module { // LLVM: %1 = alloca [10 x i32], i64 1, align 16 // LLVM-NEXT: ret void - cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES22, #cir.zero : !ty_22struct2ES22]> : !cir.array + cir.global external @arr = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S22, #cir.zero : !ty_22S22]> : !cir.array // CHECK: llvm.mlir.global external @arr() {addr_space = 0 : i32} : !llvm.array<2 x struct<"struct.S", (i32)>> { // CHECK: %0 = llvm.mlir.undef : !llvm.array<2 x struct<"struct.S", (i32)>> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"struct.S", (i32)> diff --git a/clang/test/CIR/Lowering/globals.cir b/clang/test/CIR/Lowering/globals.cir index a469ea97b43d..9833f54c3f62 100644 --- a/clang/test/CIR/Lowering/globals.cir +++ b/clang/test/CIR/Lowering/globals.cir @@ -10,8 +10,8 @@ !u32i = !cir.int !u64i = !cir.int !u8i = !cir.int -!ty_22struct2EA22 = !cir.struct<"struct.A" {!s32i, !cir.array x 2>} #cir.recdecl.ast> -!ty_22struct2EBar22 = !cir.struct<"struct.Bar" {!s32i, !s8i} #cir.recdecl.ast> +!ty_22A22 = !cir.struct x 2>} #cir.recdecl.ast> +!ty_22Bar22 = !cir.struct module { cir.global external @a = #cir.int<3> : !s32i @@ -89,7 +89,7 @@ module { cir.global external @twoDim = #cir.const_array<[#cir.const_array<[#cir.int<1> : !s32i, #cir.int<2> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.array]> : !cir.array x 2> // MLIR: llvm.mlir.global external @twoDim(dense<{{\[\[}}1, 2], [3, 4{{\]\]}}> : tensor<2x2xi32>) {addr_space = 0 : i32} : !llvm.array<2 x array<2 x i32>> // LLVM: @twoDim = global [2 x [2 x i32{{\]\] \[\[}}2 x i32] [i32 1, i32 2], [2 x i32] [i32 3, i32 4{{\]\]}} - cir.global external @nestedTwoDim = #cir.const_struct<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> : !ty_22struct2EA22 + cir.global external @nestedTwoDim = #cir.const_struct<{#cir.int<1> : !s32i, #cir.const_array<[#cir.const_array<[#cir.int<2> : !s32i, #cir.int<3> : !s32i]> : !cir.array, #cir.const_array<[#cir.int<4> : !s32i, #cir.int<5> : !s32i]> : !cir.array]> : !cir.array x 2>}> : !ty_22A22 // LLVM: @nestedTwoDim = global %struct.A { i32 1, [2 x [2 x i32{{\]\] \[\[}}2 x i32] [i32 2, i32 3], [2 x i32] [i32 4, i32 5{{\]\]}} } cir.func @_Z11get_globalsv() { %0 = cir.alloca !cir.ptr, cir.ptr >, ["s", init] {alignment = 8 : i64} @@ -140,7 +140,7 @@ module { // MLIR: %0 = llvm.mlir.zero : !llvm.ptr // MLIR: llvm.return %0 : !llvm.ptr // MLIR: } - cir.global external @zeroStruct = #cir.zero : !ty_22struct2EBar22 + cir.global external @zeroStruct = #cir.zero : !ty_22Bar22 // MLIR: llvm.mlir.global external @zeroStruct() // MLIR: %0 = cir.llvmir.zeroinit : !llvm.struct<"struct.Bar", (i32, i8)> // MLIR: llvm.return %0 : !llvm.struct<"struct.Bar", (i32, i8)> diff --git a/clang/test/CIR/Lowering/struct.cir b/clang/test/CIR/Lowering/struct.cir index 45649c1fa7f1..a5b0746fbe9c 100644 --- a/clang/test/CIR/Lowering/struct.cir +++ b/clang/test/CIR/Lowering/struct.cir @@ -4,28 +4,28 @@ !s32i = !cir.int !u8i = !cir.int !u32i = !cir.int -!ty_22struct2ES22 = !cir.struct<"struct.S" {!u8i, !s32i}> -!ty_22struct2ES2A22 = !cir.struct<"struct.S2A" {!s32i} #cir.recdecl.ast> -!ty_22struct2ES122 = !cir.struct<"struct.S1" {!s32i, f32, !cir.ptr} #cir.recdecl.ast> -!ty_22struct2ES222 = !cir.struct<"struct.S2" {!ty_22struct2ES2A22} #cir.recdecl.ast> -!ty_22struct2ES322 = !cir.struct<"struct.S3" {!s32i} #cir.recdecl.ast> +!ty_22S22 = !cir.struct +!ty_22S2A22 = !cir.struct +!ty_22S122 = !cir.struct} #cir.recdecl.ast> +!ty_22S222 = !cir.struct +!ty_22S322 = !cir.struct module { cir.func @test() { - %1 = cir.alloca !ty_22struct2ES22, cir.ptr , ["x"] {alignment = 4 : i64} + %1 = cir.alloca !ty_22S22, cir.ptr , ["x"] {alignment = 4 : i64} // CHECK: %[[#ARRSIZE:]] = llvm.mlir.constant(1 : index) : i64 // CHECK: %[[#STRUCT:]] = llvm.alloca %[[#ARRSIZE]] x !llvm.struct<"struct.S", (i8, i32)> - %3 = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "c"}> : (!cir.ptr) -> !cir.ptr + %3 = "cir.struct_element_addr"(%1) <{member_index = 0 : index, member_name = "c"}> : (!cir.ptr) -> !cir.ptr // CHECK: = llvm.getelementptr %[[#STRUCT]][0, 0] : (!llvm.ptr) -> !llvm.ptr - %5 = "cir.struct_element_addr"(%1) <{member_index = 1 : index, member_name = "i"}> : (!cir.ptr) -> !cir.ptr + %5 = "cir.struct_element_addr"(%1) <{member_index = 1 : index, member_name = "i"}> : (!cir.ptr) -> !cir.ptr // CHECK: = llvm.getelementptr %[[#STRUCT]][0, 1] : (!llvm.ptr) -> !llvm.ptr cir.return } cir.func @shouldConstInitLocalStructsWithConstStructAttr() { - %0 = cir.alloca !ty_22struct2ES2A22, cir.ptr , ["s"] {alignment = 4 : i64} - %1 = cir.const(#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES2A22) : !ty_22struct2ES2A22 - cir.store %1, %0 : !ty_22struct2ES2A22, cir.ptr + %0 = cir.alloca !ty_22S2A22, cir.ptr , ["s"] {alignment = 4 : i64} + %1 = cir.const(#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S2A22) : !ty_22S2A22 + cir.store %1, %0 : !ty_22S2A22, cir.ptr cir.return } // CHECK: llvm.func @shouldConstInitLocalStructsWithConstStructAttr() @@ -39,7 +39,7 @@ module { // CHECK: } // Should lower basic #cir.const_struct initializer. - cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, 1.000000e-01 : f32, #cir.null : !cir.ptr}> : !ty_22struct2ES122 + cir.global external @s1 = #cir.const_struct<{#cir.int<1> : !s32i, 1.000000e-01 : f32, #cir.null : !cir.ptr}> : !ty_22S122 // CHECK: llvm.mlir.global external @s1() {addr_space = 0 : i32} : !llvm.struct<"struct.S1", (i32, f32, ptr)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"struct.S1", (i32, f32, ptr)> // CHECK: %1 = llvm.mlir.constant(1 : i32) : i32 @@ -52,7 +52,7 @@ module { // CHECK: } // Should lower nested #cir.const_struct initializer. - cir.global external @s2 = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES2A22}> : !ty_22struct2ES222 + cir.global external @s2 = #cir.const_struct<{#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S2A22}> : !ty_22S222 // CHECK: llvm.mlir.global external @s2() {addr_space = 0 : i32} : !llvm.struct<"struct.S2", (struct<"struct.S2A", (i32)>)> { // CHECK: %0 = llvm.mlir.undef : !llvm.struct<"struct.S2", (struct<"struct.S2A", (i32)>)> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"struct.S2A", (i32)> @@ -62,7 +62,7 @@ module { // CHECK: llvm.return %4 : !llvm.struct<"struct.S2", (struct<"struct.S2A", (i32)>)> // CHECK: } - cir.global external @s3 = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22struct2ES322, #cir.const_struct<{#cir.int<2> : !s32i}> : !ty_22struct2ES322, #cir.const_struct<{#cir.int<3> : !s32i}> : !ty_22struct2ES322]> : !cir.array + cir.global external @s3 = #cir.const_array<[#cir.const_struct<{#cir.int<1> : !s32i}> : !ty_22S322, #cir.const_struct<{#cir.int<2> : !s32i}> : !ty_22S322, #cir.const_struct<{#cir.int<3> : !s32i}> : !ty_22S322]> : !cir.array // CHECK: llvm.mlir.global external @s3() {addr_space = 0 : i32} : !llvm.array<3 x struct<"struct.S3", (i32)>> { // CHECK: %0 = llvm.mlir.undef : !llvm.array<3 x struct<"struct.S3", (i32)>> // CHECK: %1 = llvm.mlir.undef : !llvm.struct<"struct.S3", (i32)> @@ -82,13 +82,13 @@ module { cir.func @shouldLowerStructCopies() { // CHECK: llvm.func @shouldLowerStructCopies() - %1 = cir.alloca !ty_22struct2ES22, cir.ptr , ["a"] {alignment = 4 : i64} + %1 = cir.alloca !ty_22S22, cir.ptr , ["a"] {alignment = 4 : i64} // CHECK: %[[#ONE:]] = llvm.mlir.constant(1 : index) : i64 // CHECK: %[[#SA:]] = llvm.alloca %[[#ONE]] x !llvm.struct<"struct.S", (i8, i32)> {alignment = 4 : i64} : (i64) -> !llvm.ptr - %2 = cir.alloca !ty_22struct2ES22, cir.ptr , ["b", init] {alignment = 4 : i64} + %2 = cir.alloca !ty_22S22, cir.ptr , ["b", init] {alignment = 4 : i64} // CHECK: %[[#ONE:]] = llvm.mlir.constant(1 : index) : i64 // CHECK: %[[#SB:]] = llvm.alloca %[[#ONE]] x !llvm.struct<"struct.S", (i8, i32)> {alignment = 4 : i64} : (i64) -> !llvm.ptr - cir.copy %1 to %2 : !cir.ptr + cir.copy %1 to %2 : !cir.ptr // CHECK: %[[#SIZE:]] = llvm.mlir.constant(8 : i32) : i32 // CHECK: "llvm.intr.memcpy"(%[[#SB]], %[[#SA]], %[[#SIZE]]) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () cir.return diff --git a/clang/test/CIR/Lowering/variadics.cir b/clang/test/CIR/Lowering/variadics.cir index 465f222edee4..050ae53d610c 100644 --- a/clang/test/CIR/Lowering/variadics.cir +++ b/clang/test/CIR/Lowering/variadics.cir @@ -5,30 +5,30 @@ !u32i = !cir.int !u8i = !cir.int -!ty_22struct2E__va_list_tag22 = !cir.struct<"struct.__va_list_tag" {!u32i, !u32i, !cir.ptr, !cir.ptr} #cir.recdecl.ast> +!ty_22__va_list_tag22 = !cir.struct, !cir.ptr} #cir.recdecl.ast> module { cir.func @average(%arg0: !s32i, ...) -> !s32i { %0 = cir.alloca !s32i, cir.ptr , ["count", init] {alignment = 4 : i64} %1 = cir.alloca !s32i, cir.ptr , ["__retval"] {alignment = 4 : i64} - %2 = cir.alloca !cir.array, cir.ptr >, ["args"] {alignment = 16 : i64} - %3 = cir.alloca !cir.array, cir.ptr >, ["args_copy"] {alignment = 16 : i64} + %2 = cir.alloca !cir.array, cir.ptr >, ["args"] {alignment = 16 : i64} + %3 = cir.alloca !cir.array, cir.ptr >, ["args_copy"] {alignment = 16 : i64} cir.store %arg0, %0 : !s32i, cir.ptr - %4 = cir.cast(array_to_ptrdecay, %2 : !cir.ptr>), !cir.ptr - cir.va.start %4 : !cir.ptr + %4 = cir.cast(array_to_ptrdecay, %2 : !cir.ptr>), !cir.ptr + cir.va.start %4 : !cir.ptr // MLIR: %{{[0-9]+}} = llvm.getelementptr %{{[0-9]+}}[0] : (!llvm.ptr) -> !llvm.ptr // MLIR-NEXT: %{{[0-9]+}} = llvm.bitcast %{{[0-9]+}} : !llvm.ptr to !llvm.ptr // MLIR-NEXT: llvm.intr.vastart %{{[0-9]+}} : !llvm.ptr - %5 = cir.cast(array_to_ptrdecay, %3 : !cir.ptr>), !cir.ptr - %6 = cir.cast(array_to_ptrdecay, %2 : !cir.ptr>), !cir.ptr - cir.va.copy %6 to %5 : !cir.ptr, !cir.ptr + %5 = cir.cast(array_to_ptrdecay, %3 : !cir.ptr>), !cir.ptr + %6 = cir.cast(array_to_ptrdecay, %2 : !cir.ptr>), !cir.ptr + cir.va.copy %6 to %5 : !cir.ptr, !cir.ptr // MLIR: %{{[0-9]+}} = llvm.getelementptr %{{[0-9]+}}[0] : (!llvm.ptr) -> !llvm.ptr // MLIR-NEXT: %{{[0-9]+}} = llvm.getelementptr %{{[0-9]+}}[0] : (!llvm.ptr) -> !llvm.ptr // MLIR-NEXT: %{{[0-9]+}} = llvm.bitcast %{{[0-9]+}} : !llvm.ptr to !llvm.ptr // MLIR-NEXT: %{{[0-9]+}} = llvm.bitcast %{{[0-9]+}} : !llvm.ptr to !llvm.ptr // MLIR-NEXT: llvm.intr.vacopy %13 to %{{[0-9]+}} : !llvm.ptr, !llvm.ptr - %7 = cir.cast(array_to_ptrdecay, %2 : !cir.ptr>), !cir.ptr - cir.va.end %7 : !cir.ptr + %7 = cir.cast(array_to_ptrdecay, %2 : !cir.ptr>), !cir.ptr + cir.va.end %7 : !cir.ptr // MLIR: %{{[0-9]+}} = llvm.getelementptr %{{[0-9]+}}[0] : (!llvm.ptr) -> !llvm.ptr // MLIR-NEXT: %{{[0-9]+}} = llvm.bitcast %{{[0-9]+}} : !llvm.ptr to !llvm.ptr // MLIR-NEXT: llvm.intr.vaend %{{[0-9]+}} : !llvm.ptr