https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/242059
>From befdd8a6e1f0162df2d5eba7db834987abefdff0 Mon Sep 17 00:00:00 2001 From: erichkeane <[email protected]> Date: Thu, 12 Nov 2026 13:04:06 -0800 Subject: [PATCH] [CIR] Add address_points to #cir.vtable + generation This patch adds address_points to vtable attr constants, which hold the index/offset in a vtable of the 'address point's. The 'address-point' is the split location in each element between the RTTI/offset, and the virtual function component to the vtable. This is currently not used/useful yet, as it is necessary for calculating relative-v-tables, but not for classic offset-based vtable caluclations. --- .../include/clang/CIR/Dialect/IR/CIRAttrs.td | 19 ++++-- .../CIR/Dialect/IR/CIRDialectBytecode.td | 3 +- clang/lib/CIR/CodeGen/CIRGenVTables.cpp | 8 ++- clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 23 ++++++- clang/lib/CIR/Dialect/IR/CIRDialect.cpp | 17 ++++- .../CIR/Dialect/Transforms/CXXABILowering.cpp | 3 +- clang/test/CIR/Bytecode/vtable-blockaddr.cir | 2 +- clang/test/CIR/CodeGen/multi-vtable.cpp | 6 +- clang/test/CIR/CodeGen/vbase.cpp | 2 +- clang/test/CIR/CodeGen/vtable-emission.cpp | 2 +- .../test/CIR/CodeGen/vtable-null-func-ptr.cpp | 6 +- .../vtable-nyi-nonconvertible-functype.cpp | 4 +- clang/test/CIR/CodeGen/vtt.cpp | 6 +- clang/test/CIR/CodeGenCXX/vtable-linkage.cpp | 24 +++---- .../CodeGenCXX/vtable-pure-deleted-funcs.cpp | 2 +- clang/test/CIR/IR/invalid-vtable.cir | 65 +++++++++++++++++-- clang/test/CIR/IR/vtable-attr.cir | 8 +-- clang/test/CIR/IR/vtt-addrpoint.cir | 2 +- .../CIR/Lowering/unlowered-address-spaces.cir | 2 +- .../Lowering/unsupported-type-conversions.cir | 2 +- clang/test/CIR/Lowering/vtt-addrpoint.cir | 2 +- 21 files changed, 155 insertions(+), 53 deletions(-) diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td index cd403e71418f72..9b3a03b16aeed8 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td @@ -1327,6 +1327,10 @@ def CIR_VTableAttr : CIR_ValueLikeAttr<"VTable", "vtable"> { in the case of multiple inheritence, the anonymous structure may contain multiple arrays, each of which is a vtable. + The `address_points` parameter holds the `#cir.address_point` object for + each entry in the vtable array. The address point is the 'split' location + between the offset/RTTI components and the virtual table elements. + Example 1 (single vtable): ``` cir.global linkonce_odr @_ZTV6Mother = @@ -1337,7 +1341,7 @@ def CIR_VTableAttr : CIR_ValueLikeAttr<"VTable", "vtable"> { #cir.global_view<@_ZN6Mother9MotherFooEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN6Mother10MotherFoo2Ev> : !cir.ptr<!u8i> ]> : !cir.array<!cir.ptr<!u8i> x 4> - }> : !rec_anon_struct1 + }, address_points = [<index = 0, offset = 2>]> : !rec_anon_struct1 ``` Example 2 (multiple vtables): @@ -1355,7 +1359,7 @@ def CIR_VTableAttr : CIR_ValueLikeAttr<"VTable", "vtable"> { #cir.global_view<@_ZTI5Child> : !cir.ptr<!u8i>, #cir.global_view<@_ZN6Father9FatherFooEv> : !cir.ptr<!u8i> ]> : !cir.array<!cir.ptr<!u8i> x 3> - }> : !rec_anon_struct2 + }, address_points = [<index = 0, offset = 2>, <index = 1, offset = 2>]> : !rec_anon_struct2 ``` }]; @@ -1363,19 +1367,22 @@ def CIR_VTableAttr : CIR_ValueLikeAttr<"VTable", "vtable"> { // vtable information. let parameters = (ins AttributeSelfTypeParameter<"">:$type, - "mlir::ArrayAttr":$data + "mlir::ArrayAttr":$data, + "mlir::ArrayAttr":$address_points ); let builders = [ AttrBuilderWithInferredContext<(ins "mlir::Type":$type, - "mlir::ArrayAttr":$data), [{ - return $_get(type.getContext(), type, data); + "mlir::ArrayAttr":$data, + "mlir::ArrayAttr":$address_points), [{ + return $_get(type.getContext(), type, data, address_points); }]> ]; let genVerifyDecl = 1; let assemblyFormat = [{ - `<` custom<RecordMembers>($data) `>` + `<` custom<RecordMembers>($data) `,` `address_points` `=` + $address_points `>` }]; } diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDialectBytecode.td b/clang/include/clang/CIR/Dialect/IR/CIRDialectBytecode.td index 465ff1c3c537f8..6a0444d1ec94e4 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRDialectBytecode.td +++ b/clang/include/clang/CIR/Dialect/IR/CIRDialectBytecode.td @@ -205,7 +205,8 @@ def CXXAssignAttr : DialectAttribute<(attr def VTableAttr : DialectAttribute<(attr Type:$type, - Attr<"mlir::ArrayAttr">:$data + Attr<"mlir::ArrayAttr">:$data, + Attr<"mlir::ArrayAttr">:$address_points )>; def BlockAddrDiffAttr : DialectAttribute<(attr diff --git a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp index e111cde2722c14..050bfedb17e80a 100644 --- a/clang/lib/CIR/CodeGen/CIRGenVTables.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenVTables.cpp @@ -297,7 +297,13 @@ void CIRGenVTables::createVTableInitializer(cir::GlobalOp &vtableOp, cir::ConstRecordAttr record = cgm.getBuilder().getAnonConstRecord(members); // Create a VTableAttr - auto vtableAttr = cir::VTableAttr::get(record.getType(), record.getMembers()); + SmallVector<mlir::Attribute> addressPointAttrs; + for (auto [vtableIndex, addressPoint] : llvm::enumerate(addressPoints)) + addressPointAttrs.push_back( + cir::AddressPointAttr::get(mlirContext, vtableIndex, addressPoint)); + auto vtableAttr = cir::VTableAttr::get( + record.getType(), record.getMembers(), + mlir::ArrayAttr::get(mlirContext, addressPointAttrs)); // Add the vtable initializer to the vtable global op. cgm.setInitializer(vtableOp, vtableAttr); diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp index 96f9f82e6ad869..e045d5fe5e422d 100644 --- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp @@ -976,7 +976,7 @@ cir::ConstVectorAttr::verify(function_ref<InFlightDiagnostic()> emitError, LogicalResult cir::VTableAttr::verify( llvm::function_ref<mlir::InFlightDiagnostic()> emitError, mlir::Type type, - mlir::ArrayAttr data) { + mlir::ArrayAttr data, mlir::ArrayAttr addressPoints) { auto sTy = mlir::dyn_cast_if_present<cir::RecordType>(type); if (!sTy) return emitError() << "expected !cir.struct or !cir.union type result"; @@ -986,11 +986,30 @@ LogicalResult cir::VTableAttr::verify( if (cir::ConstRecordAttr::verify(emitError, type, data).failed()) return failure(); - for (const auto &element : data.getAsRange<mlir::Attribute>()) { + if (addressPoints.size() != data.size()) + return emitError() << "expected one address point for each vtable, got " + << addressPoints.size() << " for " << data.size() + << " vtables"; + + for (const auto &[idx, element] : + llvm::enumerate(data.getAsRange<mlir::Attribute>())) { const auto &constArrayAttr = mlir::dyn_cast<cir::ConstArrayAttr>(element); if (!constArrayAttr) return emitError() << "expected constant array subtype"; + auto arrayTy = mlir::cast<cir::ArrayType>(constArrayAttr.getType()); + auto addressPoint = + mlir::dyn_cast<cir::AddressPointAttr>(addressPoints[idx]); + if (!addressPoint) + return emitError() << "expected an address point for vtable " << idx; + if (addressPoint.getIndex() != static_cast<int32_t>(idx)) + return emitError() << "address point " << idx << " refers to vtable " + << addressPoint.getIndex(); + if (addressPoint.getOffset() < 0 || + static_cast<uint64_t>(addressPoint.getOffset()) > arrayTy.getSize()) + return emitError() << "address point offset " << addressPoint.getOffset() + << " is out of range of vtable " << idx; + LogicalResult eltTypeCheck = success(); auto arrayElts = mlir::cast<ArrayAttr>(constArrayAttr.getElts()); arrayElts.walkImmediateSubElements( diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp index 83d1adb9605a60..a276ed4e2d6941 100644 --- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp +++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp @@ -2845,9 +2845,24 @@ cir::VTableAddrPointOp::verifySymbolUses(SymbolTableCollection &symbolTable) { std::optional<mlir::Attribute> init = op.getInitialValue(); if (!init) return success(); - if (!isa<cir::VTableAttr>(*init)) + auto vtable = dyn_cast<cir::VTableAttr>(*init); + if (!vtable) return emitOpError("Expected #cir.vtable in initializer for global '") << name << "'"; + + // The address point has to be the one that the vtable records for the + // array that it points into. + cir::AddressPointAttr addressPoint = getAddressPoint(); + mlir::ArrayAttr addressPoints = vtable.getAddressPoints(); + if (addressPoint.getIndex() < 0 || + static_cast<size_t>(addressPoint.getIndex()) >= addressPoints.size()) + return emitOpError("address point refers to vtable ") + << addressPoint.getIndex() << ", but '" << name << "' has " + << addressPoints.size() << " vtables"; + if (addressPoint != addressPoints[addressPoint.getIndex()]) + return emitOpError("address point ") + << addressPoint << " does not match the address point " + << addressPoints[addressPoint.getIndex()] << " of '" << name << "'"; return success(); } diff --git a/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp b/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp index bf475b5689380e..61846029bd03b5 100644 --- a/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp +++ b/clang/lib/CIR/Dialect/Transforms/CXXABILowering.cpp @@ -226,7 +226,8 @@ mlir::Attribute rewriteAttribute(const mlir::TypeConverter &tc, return cir::VTableAttr::get( tc.convertType(vta.getType()), mlir::cast<mlir::ArrayAttr>( - rewriteAttribute(tc, ctx, vta.getData()))); + rewriteAttribute(tc, ctx, vta.getData())), + vta.getAddressPoints()); }) .Case<cir::TypeInfoAttr>([&tc, ctx](cir::TypeInfoAttr tia) { return cir::TypeInfoAttr::get( diff --git a/clang/test/CIR/Bytecode/vtable-blockaddr.cir b/clang/test/CIR/Bytecode/vtable-blockaddr.cir index 2ecc209e755a05..7b2a167a5e654c 100644 --- a/clang/test/CIR/Bytecode/vtable-blockaddr.cir +++ b/clang/test/CIR/Bytecode/vtable-blockaddr.cir @@ -18,7 +18,7 @@ module { cir.global external @vt = #cir.vtable<{ #cir.const_array<[#cir.global_view<@tgt> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 1>, #cir.const_array<[#cir.global_view<@vt, [0 : i32, 2 : i32]> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 1> - }> : !cir.struct<"VT" {data !cir.array<!cir.ptr<!u8i> x 1>, data !cir.array<!cir.ptr<!u8i> x 1>}> + }, address_points = [#cir.address_point<index = 0, offset = 0>, #cir.address_point<index = 1, offset = 0>]> : !cir.struct<"VT" {data !cir.array<!cir.ptr<!u8i> x 1>, data !cir.array<!cir.ptr<!u8i> x 1>}> cir.global external @bad = #cir.block_addr_diff<@fn, "lbl", "lbl2"> : !s32i diff --git a/clang/test/CIR/CodeGen/multi-vtable.cpp b/clang/test/CIR/CodeGen/multi-vtable.cpp index 07aa8677488738..f91b3207e37774 100644 --- a/clang/test/CIR/CodeGen/multi-vtable.cpp +++ b/clang/test/CIR/CodeGen/multi-vtable.cpp @@ -51,7 +51,7 @@ void Child::MotherKey() {} // CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>, // CIR-SAME: #cir.global_view<@_ZN6Father9FatherKeyEv> : !cir.ptr<!u8i> // CIR-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 3> -// CIR-SAME: }> : [[CHILD_VTABLE_TYPE]] +// CIR-SAME: }, address_points = [#cir.address_point<index = 0, offset = 2>, #cir.address_point<index = 1, offset = 2>]> : [[CHILD_VTABLE_TYPE]] // LLVM: @_ZTV5Child = constant { [4 x ptr], [3 x ptr] } { // LLVM-SAME: [4 x ptr] [ @@ -90,7 +90,7 @@ void Child::MotherKey() {} // CIR-SAME: #cir.global_view<@_ZN6Mother9MotherKeyEv> : !cir.ptr<!u8i>, // CIR-SAME: #cir.global_view<@_ZN6Mother12MotherNonKeyEv> : !cir.ptr<!u8i> // CIR-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4> -// CIR-SAME: }> : [[MOTHER_VTABLE_TYPE]] +// CIR-SAME: }, address_points = [#cir.address_point<index = 0, offset = 2>]> : [[MOTHER_VTABLE_TYPE]] // LLVM: @_ZTV6Mother = constant { [4 x ptr] } { // LLVM-SAME: [4 x ptr] [ @@ -118,7 +118,7 @@ void Child::MotherKey() {} // CIR-SAME: #cir.ptr<null> : !cir.ptr<!u8i>, // CIR-SAME: #cir.global_view<@_ZN6Father9FatherKeyEv> : !cir.ptr<!u8i> // CIR-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 3> -// CIR-SAME: }> : [[FATHER_VTABLE_TYPE]] +// CIR-SAME: }, address_points = [#cir.address_point<index = 0, offset = 2>]> : [[FATHER_VTABLE_TYPE]] // LLVM: @_ZTV6Father = constant { [3 x ptr] } { // LLVM-SAME: [3 x ptr] [ diff --git a/clang/test/CIR/CodeGen/vbase.cpp b/clang/test/CIR/CodeGen/vbase.cpp index 91036922f213eb..f8036263a11512 100644 --- a/clang/test/CIR/CodeGen/vbase.cpp +++ b/clang/test/CIR/CodeGen/vbase.cpp @@ -51,7 +51,7 @@ void ppp() { B b; } // Note: OGCG speculatively emits the VTT and VTables. This is not yet implemented in CIR. // Vtable definition for B -// CIR: cir.global {{.*}}@_ZTV1B = #cir.vtable<{#cir.const_array<[#cir.ptr<12 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1B> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !rec_anon_struct3 align(8) +// CIR: cir.global {{.*}}@_ZTV1B = #cir.vtable<{#cir.const_array<[#cir.ptr<12 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1B> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 3>]> : !rec_anon_struct3 align(8) // LLVM: @_ZTV1B = linkonce_odr constant { [3 x ptr] } { [3 x ptr] [ptr inttoptr (i64 12 to ptr), ptr null, ptr @_ZTI1B] }, comdat, align 8 // OGCG: @_ZTV1B = linkonce_odr constant { [3 x ptr] } { [3 x ptr] [ptr inttoptr (i64 12 to ptr), ptr null, ptr @_ZTI1B] }, comdat, align 8 diff --git a/clang/test/CIR/CodeGen/vtable-emission.cpp b/clang/test/CIR/CodeGen/vtable-emission.cpp index b6f49b949aba08..165bf5a2290d93 100644 --- a/clang/test/CIR/CodeGen/vtable-emission.cpp +++ b/clang/test/CIR/CodeGen/vtable-emission.cpp @@ -24,7 +24,7 @@ void S::key() {} // CHECK-SAME: #cir.ptr<null> : !cir.ptr<!u8i>, // CHECK-SAME: #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, // CHECK-SAME: #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> -// CHECK-SAME: : !cir.array<!cir.ptr<!u8i> x 4>}> : !rec_anon_struct +// CHECK-SAME: : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !rec_anon_struct // LLVM: @_ZTV1S = {{(unnamed_addr )?}}constant { [4 x ptr] } { [4 x ptr] // LLVM-SAME: [ptr null, ptr null, ptr @_ZN1S3keyEv, ptr @_ZN1S6nonKeyEv] } diff --git a/clang/test/CIR/CodeGen/vtable-null-func-ptr.cpp b/clang/test/CIR/CodeGen/vtable-null-func-ptr.cpp index a0f9192e68801c..0e7fbc1d7efca5 100644 --- a/clang/test/CIR/CodeGen/vtable-null-func-ptr.cpp +++ b/clang/test/CIR/CodeGen/vtable-null-func-ptr.cpp @@ -17,14 +17,14 @@ struct D : public B, public C { }; void D::d() {} -// CIR: cir.global {{.*}}@_ZTV1D = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1A1fEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1D1dEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 6>, #cir.const_array<[#cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}> +// CIR: cir.global {{.*}}@_ZTV1D = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1A1fEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1D1dEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 6>, #cir.const_array<[#cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}, address_points = [#cir.address_point<index = 0, offset = 4>, #cir.address_point<index = 1, offset = 4>]> // // LLVM: @_ZTV1D = {{.*}}{ [6 x ptr], [5 x ptr] } { [6 x ptr] [ptr null, ptr null, ptr null, ptr @_ZTI1D, ptr @_ZN1A1fEv, ptr @_ZN1D1dEv], [5 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr @_ZTI1D, ptr null] }, align 8 // -// CIR: cir.global {{.*}}@_ZTC1D0_1B = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1B> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1A1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}> +// CIR: cir.global {{.*}}@_ZTC1D0_1B = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1B> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1A1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}, address_points = [#cir.address_point<index = 0, offset = 4>]> // LLVM: @_ZTC1D0_1B = {{.*}}{ [5 x ptr] } { [5 x ptr] [ptr null, ptr null, ptr null, ptr @_ZTI1B, ptr @_ZN1A1fEv] }, align 8 // -// CIR: cir.global {{.*}}@_ZTC1D16_1C = #cir.vtable<{#cir.const_array<[#cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>, #cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<16 : i64> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1A1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> +// CIR: cir.global {{.*}}@_ZTC1D16_1C = #cir.vtable<{#cir.const_array<[#cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<-16 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>, #cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<16 : i64> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1A1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 4>, #cir.address_point<index = 1, offset = 3>]> // // LLVM: @_ZTC1D16_1C = {{.*}}{ [5 x ptr], [4 x ptr] } { [5 x ptr] [ptr inttoptr (i64 -16 to ptr), ptr inttoptr (i64 -16 to ptr), ptr null, ptr @_ZTI1C, ptr null], [4 x ptr] [ptr null, ptr inttoptr (i64 16 to ptr), ptr @_ZTI1C, ptr @_ZN1A1fEv] }, align 8 diff --git a/clang/test/CIR/CodeGen/vtable-nyi-nonconvertible-functype.cpp b/clang/test/CIR/CodeGen/vtable-nyi-nonconvertible-functype.cpp index 1f047ef5027778..73da70ffcfb956 100644 --- a/clang/test/CIR/CodeGen/vtable-nyi-nonconvertible-functype.cpp +++ b/clang/test/CIR/CodeGen/vtable-nyi-nonconvertible-functype.cpp @@ -27,7 +27,7 @@ void S1::key() {} // CIR-SAME: #cir.global_view<@_ZTI2S1> : !cir.ptr<!u8i>, // CIR-SAME: #cir.global_view<@_ZN2S13keyEv> : !cir.ptr<!u8i>, // CIR-SAME: #cir.global_view<@_ZN2S19badReturnEv> : !cir.ptr<!u8i>]> : -// CIR-SAME: !cir.array<!cir.ptr<!u8i> x 4>}> +// CIR-SAME: !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> // LLVM: @_ZTV2S1 = {{.*}}{ [4 x ptr] } { [4 x ptr] [ // LLVM-SAME: ptr null, @@ -49,7 +49,7 @@ void S2::key() {} // CIR-SAME: #cir.global_view<@_ZTI2S2> : !cir.ptr<!u8i>, // CIR-SAME: #cir.global_view<@_ZN2S23keyEv> : !cir.ptr<!u8i>, // CIR-SAME: #cir.global_view<@_ZN2S28badParamE6Param2> : !cir.ptr<!u8i>]> : -// CIR-SAME: !cir.array<!cir.ptr<!u8i> x 4>}> +// CIR-SAME: !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> // LLVM: @_ZTV2S2 = {{.*}}{ [4 x ptr] } { [4 x ptr] [ // LLVM-SAME: ptr null, diff --git a/clang/test/CIR/CodeGen/vtt.cpp b/clang/test/CIR/CodeGen/vtt.cpp index 4b7f605edc8534..0a6dfc4d4e089a 100644 --- a/clang/test/CIR/CodeGen/vtt.cpp +++ b/clang/test/CIR/CodeGen/vtt.cpp @@ -83,7 +83,7 @@ void D::y() {} // CIR-RTTI-SAME: #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>, // CIR-COMMON-SAME: #cir.global_view<@_ZN1A1vEv> : !cir.ptr<!u8i> // CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4> -// CIR-COMMON-SAME: }> : ![[REC_D_VTABLE]] align(8) +// CIR-COMMON-SAME: }, address_points = [#cir.address_point<index = 0, offset = 3>, #cir.address_point<index = 1, offset = 3>, #cir.address_point<index = 2, offset = 3>]> : ![[REC_D_VTABLE]] align(8) // LLVM-COMMON: @_ZTV1D = constant { [5 x ptr], [4 x ptr], [4 x ptr] } { // LLVM-NO-RTTI-SAME: [5 x ptr] [ptr inttoptr (i64 40 to ptr), ptr null, ptr null, ptr @_ZN1B1wEv, ptr @_ZN1D1yEv], @@ -153,7 +153,7 @@ void D::y() {} // CIR-RTTI-SAME: #cir.global_view<@_ZTI1B> : !cir.ptr<!u8i>, // CIR-COMMON-SAME: #cir.global_view<@_ZN1A1vEv> : !cir.ptr<!u8i> // CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4> -// CIR-COMMON-SAME: }> : ![[REC_B_OR_C_IN_D_VTABLE]] +// CIR-COMMON-SAME: }, address_points = [#cir.address_point<index = 0, offset = 3>, #cir.address_point<index = 1, offset = 3>]> : ![[REC_B_OR_C_IN_D_VTABLE]] // LLVM-COMMON: @_ZTC1D0_1B = constant { [4 x ptr], [4 x ptr] } { // LLVM-NO-RTTI-SAME: [4 x ptr] [ptr inttoptr (i64 40 to ptr), ptr null, ptr null, ptr @_ZN1B1wEv], @@ -191,7 +191,7 @@ void D::y() {} // CIR-NO-RTTI-SAME: #cir.ptr<null> : !cir.ptr<!u8i>, // CIR-RTTI-SAME: #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, // CIR-COMMON-SAME: #cir.global_view<@_ZN1A1vEv> : !cir.ptr<!u8i> -// CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4>}> +// CIR-COMMON-SAME: ]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 3>, #cir.address_point<index = 1, offset = 3>]> // CIR-COMMON-SAME: : ![[REC_B_OR_C_IN_D_VTABLE]] // LLVM-COMMON: @_ZTC1D16_1C = constant { [4 x ptr], [4 x ptr] } { diff --git a/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp b/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp index a3627d8424bf8a..9345542ebd8630 100644 --- a/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp +++ b/clang/test/CIR/CodeGenCXX/vtable-linkage.cpp @@ -114,7 +114,7 @@ void use_F() { // C has no key function, so its vtable should have weak_odr linkage // and hidden visibility. -// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1C1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1C> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1C1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}, address_points = [#cir.address_point<index = 0, offset = 4>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTS1C = #cir.const_array<"1C" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3> align(1) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTI1C = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv121__vmi_class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1C> : !cir.ptr<!u8i>, #cir.int<0> : !u32i, #cir.int<1> : !u32i, #cir.global_view<@_ZTI1B> : !cir.ptr<!u8i>, #cir.int<-8189> : !s64i}> : !{{.*}}align(8) // CIR-DAG: cir.global constant linkonce_odr comdat unnamed_addr @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 4 : i32], address_point true> : !cir.ptr<!u8i>, #cir.global_view<@_ZTV1C, [0 : i32, 4 : i32], address_point true> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2> align(8) @@ -125,7 +125,7 @@ void use_F() { // D has a key function that is defined in this translation unit so its vtable is // defined in the translation unit. -// CIR-DAG: cir.global constant external @_ZTV1D = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1D1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant external @_ZTV1D = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1D1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant external @_ZTS1D = #cir.const_array<"1D" : !cir.array<!s8i x 2>, trailing_zeros> : !cir.array<!s8i x 3> align(1) // CIR-DAG: cir.global constant external @_ZTI1D = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1D> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1D = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1D, ptr @_ZN1D1fEv] }, align 8 @@ -135,7 +135,7 @@ void use_F() { // E<char> is an explicit specialization with a key function defined // in this translation unit, so its vtable should have external // linkage. -// CIR-DAG: cir.global constant external @_ZTV1EIcE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1EIcE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIcE6anchorEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant external @_ZTV1EIcE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1EIcE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIcE6anchorEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant external @_ZTS1EIcE = #cir.const_array<"1EIcE" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1) // CIR-DAG: cir.global constant external @_ZTI1EIcE = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1EIcE> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1EIcE = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1EIcE, ptr @_ZN1EIcE6anchorEv] }, align 8 @@ -145,7 +145,7 @@ void use_F() { // E<short> is an explicit template instantiation with a key function // defined in this translation unit, so its vtable should have // weak_odr linkage. -// CIR-DAG: cir.global constant weak_odr comdat @_ZTV1EIsE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1EIsE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIsED1Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIsED0Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant weak_odr comdat @_ZTV1EIsE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1EIsE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIsED1Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIsED0Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant weak_odr comdat @_ZTI1EIsE = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1EIsE> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // CIR-DAG: cir.global constant weak_odr comdat @_ZTS1EIsE = #cir.const_array<"1EIsE" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1) // LLVM-DAG: @_ZTV1EIsE = weak_odr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI1EIsE, ptr @_ZN1EIsED1Ev, ptr @_ZN1EIsED0Ev] }, comdat, align 8 @@ -154,7 +154,7 @@ void use_F() { // F<short> is an explicit template instantiation without a key // function, so its vtable should have weak_odr linkage -// CIR-DAG: cir.global constant weak_odr comdat @_ZTV1FIsE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1FIsE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1FIsE3fooEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant weak_odr comdat @_ZTV1FIsE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1FIsE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1FIsE3fooEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant weak_odr comdat @_ZTS1FIsE = #cir.const_array<"1FIsE" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1) // CIR-DAG: cir.global constant weak_odr comdat @_ZTI1FIsE = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1FIsE> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1FIsE = weak_odr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1FIsE, ptr @_ZN1FIsE3fooEv] }, comdat, align 8 @@ -164,7 +164,7 @@ void use_F() { // E<long> is an implicit template instantiation with a key function // defined in this translation unit, so its vtable should have // linkonce_odr linkage. -// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1EIlE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1EIlE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIlED1Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIlED0Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1EIlE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1EIlE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIlED1Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1EIlED0Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTS1EIlE = #cir.const_array<"1EIlE" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTI1EIlE = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1EIlE> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1EIlE = linkonce_odr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI1EIlE, ptr @_ZN1EIlED1Ev, ptr @_ZN1EIlED0Ev] }, comdat, align 8 @@ -173,7 +173,7 @@ void use_F() { // F<long> is an implicit template instantiation with no key function, // so its vtable should have linkonce_odr linkage. -// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1FIlE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1FIlE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1FIlE3fooEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1FIlE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1FIlE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1FIlE3fooEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTS1FIlE = #cir.const_array<"1FIlE" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTI1FIlE = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1FIlE> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1FIlE = linkonce_odr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1FIlE, ptr @_ZN1FIlE3fooEv] }, comdat, align 8 @@ -196,7 +196,7 @@ void use_F() { // The anonymous struct for e has no linkage, so the vtable should have // internal linkage. -// CIR-DAG: cir.global "private" constant internal dso_local @_ZTV3$_0 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI3$_0> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1D1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !{{.*}}align(8) +// CIR-DAG: cir.global "private" constant internal dso_local @_ZTV3$_0 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI3$_0> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1D1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global "private" constant internal dso_local @_ZTS3$_0 = #cir.const_array<"3$_0" : !cir.array<!s8i x 4>, trailing_zeros> : !cir.array<!s8i x 5> align(1) // CIR-DAG: cir.global "private" constant internal dso_local @_ZTI3$_0 = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS3$_0> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1D> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @"_ZTV3$_0" = internal constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @"_ZTI3$_0", ptr @_ZN1D1fEv] }, align 8 @@ -205,7 +205,7 @@ void use_F() { // The A vtable should have internal linkage since it is inside an anonymous // namespace. -// CIR-DAG: cir.global "private" constant internal dso_local @_ZTVN12_GLOBAL__N_11AE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTIN12_GLOBAL__N_11AE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN12_GLOBAL__N_11A1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !{{.*}}align(8) +// CIR-DAG: cir.global "private" constant internal dso_local @_ZTVN12_GLOBAL__N_11AE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTIN12_GLOBAL__N_11AE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN12_GLOBAL__N_11A1fEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global "private" constant internal dso_local @_ZTSN12_GLOBAL__N_11AE = #cir.const_array<"N12_GLOBAL__N_11AE" : !cir.array<!s8i x 18>, trailing_zeros> : !cir.array<!s8i x 19> align(1) // CIR-DAG: cir.global "private" constant internal dso_local @_ZTIN12_GLOBAL__N_11AE = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTSN12_GLOBAL__N_11AE> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @_ZTVN12_GLOBAL__N_11AE = internal constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTIN12_GLOBAL__N_11AE, ptr @_ZN12_GLOBAL__N_11A1fEv] }, align 8 @@ -214,14 +214,14 @@ void use_F() { // F<char> is an explicit specialization without a key function, so // its vtable should have linkonce_odr linkage. -// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1FIcE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1FIcE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1FIcE3fooEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1FIcE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1FIcE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1FIcE3fooEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTS1FIcE = #cir.const_array<"1FIcE" : !cir.array<!s8i x 5>, trailing_zeros> : !cir.array<!s8i x 6> align(1) // CIR-DAG: cir.global constant linkonce_odr comdat @_ZTI1FIcE = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS1FIcE> : !cir.ptr<!u8i>}> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1FIcE = linkonce_odr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr @_ZTI1FIcE, ptr @_ZN1FIcE3fooEv] }, comdat, align 8 // LLVM-DAG: @_ZTS1FIcE = linkonce_odr constant [6 x i8] c"1FIcE\00", comdat, align 1 // LLVM-DAG: @_ZTI1FIcE = linkonce_odr constant { ptr, ptr } { ptr getelementptr {{.*}}({{.*}}, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i64 {{.*}}), ptr @_ZTS1FIcE }, comdat -// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1GIiE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1GIiE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1GIiE2f0Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1GIiE2f1Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1GIiE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1GIiE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1GIiE2f0Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1GIiE2f1Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1GIiE = linkonce_odr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI1GIiE, ptr @_ZN1GIiE2f0Ev, ptr @_ZN1GIiE2f1Ev] }, comdat, align 8 template <typename T> class G { @@ -238,7 +238,7 @@ void G_f0() { new G<int>(); } // H<int> has a key function without a body but it's a template instantiation // so its VTable must be emitted. -// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1HIiE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1HIiE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1HIiED1Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1HIiED0Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !{{.*}}align(8) +// CIR-DAG: cir.global constant linkonce_odr comdat @_ZTV1HIiE = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI1HIiE> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1HIiED1Ev> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1HIiED0Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !{{.*}}align(8) // LLVM-DAG: @_ZTV1HIiE = linkonce_odr constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr @_ZTI1HIiE, ptr @_ZN1HIiED1Ev, ptr @_ZN1HIiED0Ev] }, comdat, align 8 template <typename T> class H { diff --git a/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp b/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp index 314f889f6d2d4f..b7ca02ec7d59d5 100644 --- a/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp +++ b/clang/test/CIR/CodeGenCXX/vtable-pure-deleted-funcs.cpp @@ -13,7 +13,7 @@ struct Struct { void Struct::f3(){} -// CIR: cir.global constant external @_ZTV6Struct = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI6Struct> : !cir.ptr<!u8i>, #cir.global_view<@__cxa_pure_virtual> : !cir.ptr<!u8i>, #cir.global_view<@__cxa_deleted_virtual> : !cir.ptr<!u8i>, #cir.global_view<@_ZN6Struct2f3Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}> +// CIR: cir.global constant external @_ZTV6Struct = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZTI6Struct> : !cir.ptr<!u8i>, #cir.global_view<@__cxa_pure_virtual> : !cir.ptr<!u8i>, #cir.global_view<@__cxa_deleted_virtual> : !cir.ptr<!u8i>, #cir.global_view<@_ZN6Struct2f3Ev> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 5>}, address_points = [#cir.address_point<index = 0, offset = 2>]> // LLVM: @_ZTV6Struct = constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI6Struct, ptr @__cxa_pure_virtual, ptr @__cxa_deleted_virtual, ptr @_ZN6Struct2f3Ev] } // CIR: cir.global constant external @_ZTI6Struct = #cir.typeinfo<{#cir.global_view<@_ZTVN10__cxxabiv117__class_type_infoE, [2 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTS6Struct> : !cir.ptr<!u8i>}> diff --git a/clang/test/CIR/IR/invalid-vtable.cir b/clang/test/CIR/IR/invalid-vtable.cir index 59b2c4faa22655..92d70cb7a2ac25 100644 --- a/clang/test/CIR/IR/invalid-vtable.cir +++ b/clang/test/CIR/IR/invalid-vtable.cir @@ -25,7 +25,7 @@ cir.func @reference_non_vtable() { !rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>}> module { // expected-error @below {{expected !cir.struct or !cir.union type result}} - cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !cir.ptr<!rec_anon_struct> + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !cir.ptr<!rec_anon_struct> cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr<!rec_S>) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr<!rec_S>) } @@ -37,7 +37,7 @@ module { !rec_anon_struct = !cir.struct<{}> module { // expected-error @below {{expected record type with one or more subtype}} - cir.global external @_ZTV1S = #cir.vtable<{}> : !rec_anon_struct align(8) + cir.global external @_ZTV1S = #cir.vtable<{}, address_points = []> : !rec_anon_struct align(8) cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr<!rec_S>) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr<!rec_S>) } @@ -49,7 +49,7 @@ module { !rec_anon_struct = !cir.struct<{data !cir.ptr<!u8i>}> module { // expected-error @below {{expected constant array subtype}} - cir.global external @_ZTV1S = #cir.vtable<{#cir.ptr<null> : !cir.ptr<!u8i>}> : !rec_anon_struct align(8) + cir.global external @_ZTV1S = #cir.vtable<{#cir.ptr<null> : !cir.ptr<!u8i>}, address_points = [#cir.address_point<index = 0, offset = 0>]> : !rec_anon_struct align(8) cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr<!rec_S>) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr<!rec_S>) } @@ -61,7 +61,7 @@ module { !rec_anon_struct = !cir.struct<{data !cir.array<!u64i x 4>}> module { // expected-error @below {{expected GlobalViewAttr or ConstPtrAttr}} - cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.int<1> : !u64i, #cir.int<1> : !u64i, #cir.int<3> : !u64i, #cir.int<4> : !u64i]> : !cir.array<!u64i x 4>}> : !rec_anon_struct align(8) + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.int<1> : !u64i, #cir.int<1> : !u64i, #cir.int<3> : !u64i, #cir.int<4> : !u64i]> : !cir.array<!u64i x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !rec_anon_struct align(8) cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr<!rec_S>) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr<!rec_S>) } @@ -75,7 +75,7 @@ module { !rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>, data !cir.ptr<!u8i>}> module { // expected-error @below {{expected constant array subtype}} - cir.global external @_ZTV2S2 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>, #cir.ptr<null> : !cir.ptr<!u8i>}> : !rec_anon_struct align(8) + cir.global external @_ZTV2S2 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>, #cir.ptr<null> : !cir.ptr<!u8i>}, address_points = [#cir.address_point<index = 0, offset = 2>, #cir.address_point<index = 1, offset = 0>]> : !rec_anon_struct align(8) cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr<!rec_S>) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr<!rec_S>) @@ -98,7 +98,7 @@ cir.func @reference_unknown_vtt() { !u32i = !cir.int<u, 32> !void = !cir.void !rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>}> -cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !rec_anon_struct align(8) +cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !rec_anon_struct align(8) cir.func @reference_non_vtt() { // expected-error @below {{'cir.vtt.address_point' op Expected constant array in initializer for global VTT '_ZTV1S'}} %0 = cir.vtt.address_point @_ZTV1S, offset = 1 -> !cir.ptr<!cir.ptr<!void>> @@ -143,3 +143,56 @@ cir.func @vtt_addrpoint_addrspace_mismatch() { %0 = cir.vtt.address_point @_ZTT1C, offset = 1 -> !cir.ptr<!cir.ptr<!void>, target_address_space(1)> cir.return } + +// ----- + +!u8i = !cir.int<u, 8> +!rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 2>}> +module { + // expected-error @below {{expected one address point for each vtable, got 2 for 1 vtables}} + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2>}, address_points = [#cir.address_point<index = 0, offset = 0>, #cir.address_point<index = 1, offset = 1>]> : !rec_anon_struct align(8) +} + +// ----- + +!u8i = !cir.int<u, 8> +!rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 2>}> +module { + // expected-error @below {{address point offset 3 is out of range of vtable 0}} + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2>}, address_points = [#cir.address_point<index = 0, offset = 3>]> : !rec_anon_struct align(8) +} + +// ----- + +!u8i = !cir.int<u, 8> +!rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>}> +module { + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !rec_anon_struct align(8) + cir.func @address_point_mismatch() { + // expected-error @below {{address point #cir.address_point<index = 0, offset = 3> does not match the address point #cir.address_point<index = 0, offset = 2> of '_ZTV1S'}} + %0 = cir.vtable.address_point(@_ZTV1S, address_point = <index = 0, offset = 3>) : !cir.vptr + cir.return + } +} + +// ----- + +!u8i = !cir.int<u, 8> +!rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>}> +module { + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !rec_anon_struct align(8) + cir.func @address_point_wrong_vtable() { + // expected-error @below {{address point refers to vtable 1, but '_ZTV1S' has 1 vtables}} + %0 = cir.vtable.address_point(@_ZTV1S, address_point = <index = 1, offset = 2>) : !cir.vptr + cir.return + } +} + +// ----- + +!u8i = !cir.int<u, 8> +!rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 2>}> +module { + // expected-error @below {{address point 0 refers to vtable 1}} + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2>}, address_points = [#cir.address_point<index = 1, offset = 0>]> : !rec_anon_struct align(8) +} diff --git a/clang/test/CIR/IR/vtable-attr.cir b/clang/test/CIR/IR/vtable-attr.cir index 88fba3d2ac0d6b..4b26b13a67672f 100644 --- a/clang/test/CIR/IR/vtable-attr.cir +++ b/clang/test/CIR/IR/vtable-attr.cir @@ -7,11 +7,11 @@ !rec_anon_struct = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>}> !rec_anon_struct1 = !cir.struct<{data !cir.array<!cir.ptr<!u8i> x 4>, data !cir.array<!cir.ptr<!u8i> x 3>}> module { - cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !rec_anon_struct align(8) - // CHECK: cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}> : !rec_anon_struct align(8) + cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !rec_anon_struct align(8) + // CHECK: cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>}, address_points = [#cir.address_point<index = 0, offset = 2>]> : !rec_anon_struct align(8) - cir.global external @_ZTV2S2 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>, #cir.const_array<[#cir.ptr<-8 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN2S23keyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !rec_anon_struct1 align(8) - // CHECK: cir.global external @_ZTV2S2 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>, #cir.const_array<[#cir.ptr<-8 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN2S23keyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !rec_anon_struct1 align(8) + cir.global external @_ZTV2S2 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>, #cir.const_array<[#cir.ptr<-8 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN2S23keyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>, #cir.address_point<index = 1, offset = 2>]> : !rec_anon_struct1 align(8) + // CHECK: cir.global external @_ZTV2S2 = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 4>, #cir.const_array<[#cir.ptr<-8 : i64> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.global_view<@_ZN2S23keyEv> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 2>, #cir.address_point<index = 1, offset = 2>]> : !rec_anon_struct1 align(8) cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr<!rec_S>) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr<!rec_S>) diff --git a/clang/test/CIR/IR/vtt-addrpoint.cir b/clang/test/CIR/IR/vtt-addrpoint.cir index 8e255e900b450c..42221760bb9e35 100644 --- a/clang/test/CIR/IR/vtt-addrpoint.cir +++ b/clang/test/CIR/IR/vtt-addrpoint.cir @@ -32,7 +32,7 @@ module { cir.store align(8) %8, %9 : !cir.vptr, !cir.ptr<!cir.vptr> cir.return } - cir.global linkonce_odr dso_local @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !rec_anon_struct align(8) + cir.global linkonce_odr dso_local @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 3>]> : !rec_anon_struct align(8) cir.global linkonce_odr @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 3 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTC1C0_1B, [0 : i32, 3 : i32]> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2> align(8) cir.func dso_local @_ZN1CC1Ev(%arg0: !cir.ptr<!rec_C>) { %0 = cir.alloca "this" align(8) init : !cir.ptr<!cir.ptr<!rec_C>> diff --git a/clang/test/CIR/Lowering/unlowered-address-spaces.cir b/clang/test/CIR/Lowering/unlowered-address-spaces.cir index c58d1fe26c4cf1..ded4b5ca6b20ea 100644 --- a/clang/test/CIR/Lowering/unlowered-address-spaces.cir +++ b/clang/test/CIR/Lowering/unlowered-address-spaces.cir @@ -131,7 +131,7 @@ module attributes {cir.triple = "x86_64-unknown-linux-gnu"} { // Lower the view before its target, including through enclosing attributes. // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.array<!cir.ptr<!cir.int<s, 32>, lang_address_space(offload_global)> x 1>' for symbol @target}} // expected-error @below {{failed to legalize operation 'cir.global'}} - cir.global external @view = #cir.vtable<{#cir.const_array<[#cir.global_view<@target, [0 : i32]> : !ptr]> : !ptrarray}> : !vtable + cir.global external @view = #cir.vtable<{#cir.const_array<[#cir.global_view<@target, [0 : i32]> : !ptr]> : !ptrarray}, address_points = [#cir.address_point<index = 0, offset = 0>]> : !vtable cir.global external @target = #cir.zero : !array } diff --git a/clang/test/CIR/Lowering/unsupported-type-conversions.cir b/clang/test/CIR/Lowering/unsupported-type-conversions.cir index 7740caf51f9393..1a75410dc1a358 100644 --- a/clang/test/CIR/Lowering/unsupported-type-conversions.cir +++ b/clang/test/CIR/Lowering/unsupported-type-conversions.cir @@ -184,7 +184,7 @@ module attributes {cir.triple = "x86_64-unknown-linux-gnu"} { // Propagate initializer failure before lowering the referenced global. // expected-error @below {{ClangIR lowering NYI: cannot convert '!cir.vector<4 x !cir.int<s, 7, bitint>>'}} // expected-error @below {{failed to legalize operation 'cir.global'}} - cir.global external @vtable_view = #cir.vtable<{#cir.const_array<[#cir.global_view<@target, [0 : i32]> : !ptr]> : !cir.array<!ptr x 1>}> : !cir.struct<{data !cir.array<!ptr x 1>}> + cir.global external @vtable_view = #cir.vtable<{#cir.const_array<[#cir.global_view<@target, [0 : i32]> : !ptr]> : !cir.array<!ptr x 1>}, address_points = [#cir.address_point<index = 0, offset = 0>]> : !cir.struct<{data !cir.array<!ptr x 1>}> cir.global external @target = #cir.zero : !vec } diff --git a/clang/test/CIR/Lowering/vtt-addrpoint.cir b/clang/test/CIR/Lowering/vtt-addrpoint.cir index e13a64ce3ff124..24eab5ceefc019 100644 --- a/clang/test/CIR/Lowering/vtt-addrpoint.cir +++ b/clang/test/CIR/Lowering/vtt-addrpoint.cir @@ -35,7 +35,7 @@ module { // CHECK: %[[VTT:.*]] = getelementptr inbounds ptr, ptr %{{.*}}, i32 1 // CHECK: call void @_ZN1BC2Ev(ptr %{{.*}}, ptr %[[VTT]]) - cir.global linkonce_odr dso_local @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}> : !rec_anon_struct align(8) + cir.global linkonce_odr dso_local @_ZTV1C = #cir.vtable<{#cir.const_array<[#cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>, #cir.ptr<null> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 3>}, address_points = [#cir.address_point<index = 0, offset = 3>]> : !rec_anon_struct align(8) cir.global linkonce_odr @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 3 : i32]> : !cir.ptr<!u8i>, #cir.global_view<@_ZTC1C0_1B, [0 : i32, 3 : i32]> : !cir.ptr<!u8i>]> : !cir.array<!cir.ptr<!u8i> x 2> align(8) cir.func dso_local @_ZN1CC1Ev(%arg0: !cir.ptr<!rec_C>) { %0 = cir.alloca "this" align(8) init : !cir.ptr<!cir.ptr<!rec_C>> _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
