Author: Erich Keane Date: 2026-11-17T11:56:00-08:00 New Revision: 1b6582c154fd39a8b45bc3dc46cf645b68a7e371
URL: https://github.com/llvm/llvm-project/commit/1b6582c154fd39a8b45bc3dc46cf645b68a7e371 DIFF: https://github.com/llvm/llvm-project/commit/1b6582c154fd39a8b45bc3dc46cf645b68a7e371.diff LOG: [CIR][NFC] Remove a pair of RelativeVTable checks that are not needed (#243511) The following 2 checks are not currently reachable. The Itanium CXXABI fix is now going to be handled during lowering, and the CIRGenClass issue is hidden by other diagnostics. This cleans the two up. Added: Modified: clang/lib/CIR/CodeGen/CIRGenClass.cpp clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp Removed: ################################################################################ diff --git a/clang/lib/CIR/CodeGen/CIRGenClass.cpp b/clang/lib/CIR/CodeGen/CIRGenClass.cpp index 38e9d8bb4aa92..e5f4786dc679d 100644 --- a/clang/lib/CIR/CodeGen/CIRGenClass.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenClass.cpp @@ -637,12 +637,9 @@ static Address applyNonVirtualAndVirtualOffset( mlir::Value baseOffset; if (!nonVirtualOffset.isZero()) { if (virtualOffset) { - mlir::Type offsetType = - (cgf.cgm.getTarget().getCXXABI().isItaniumFamily() && - cgf.cgm.getLangOpts().RelativeCXXABIVTables) - ? cgf.sInt32Ty - : cgf.ptrDiffTy; - baseOffset = cgf.getBuilder().getConstInt(loc, offsetType, + // The virtual offset is always a ptr diff _t: how it is stored in the + // vtable is up to the lowering of cir.vtable.get_offset. + baseOffset = cgf.getBuilder().getConstInt(loc, cgf.ptrDiffTy, nonVirtualOffset.getQuantity()); baseOffset = cgf.getBuilder().createAdd(loc, virtualOffset, baseOffset); } else { diff --git a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp index 4ca4ed59a5ee9..067a95259808b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp @@ -1645,25 +1645,20 @@ CIRGenCallee CIRGenItaniumCXXABI::getVirtualFunctionPointer( } else { assert(!cir::MissingFeatures::emitTypeMetadataCodeForVCall()); - if (cgm.getLangOpts().RelativeCXXABIVTables) { - assert(!cir::MissingFeatures::vtableRelativeLayout()); - cgm.errorNYI(loc, "getVirtualFunctionPointer: isRelativeLayout"); - } else { - auto vfuncOp = cir::VTableGetVirtualFnOp::create(builder, loc, tyPtr, - vtable, vtableIndex); - - // Set invariant on the virtual function pointer load to indicate that - // function didn't change inside vtable. - // It's safe to add it without -fstrict-vtable-pointers, but it would not - // help in devirtualization because it will only matter if we will have 2 - // the same virtual function loads from the same vtable load, which won't - // happen without enabled devirtualization with -fstrict-vtable-pointers. - if (cgm.getCodeGenOpts().OptimizationLevel > 0 && - cgm.getCodeGenOpts().StrictVTablePointers) - vfuncOp.setInvariant(true); - - vfunc = vfuncOp; - } + auto vfuncOp = cir::VTableGetVirtualFnOp::create(builder, loc, tyPtr, + vtable, vtableIndex); + + // Set invariant on the virtual function pointer load to indicate that + // function didn't change inside vtable. + // It's safe to add it without -fstrict-vtable-pointers, but it would not + // help in devirtualization because it will only matter if we will have 2 + // the same virtual function loads from the same vtable load, which won't + // happen without enabled devirtualization with -fstrict-vtable-pointers. + if (cgm.getCodeGenOpts().OptimizationLevel > 0 && + cgm.getCodeGenOpts().StrictVTablePointers) + vfuncOp.setInvariant(true); + + vfunc = vfuncOp; } CIRGenCallee callee(gd, vfunc.getDefiningOp()); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
