[clang] [CIR] Add TBAA for vtable pointers, aggregate copies, atomics and complex (PR #247722)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 03:51:57 PST 2026


================
@@ -1916,10 +1920,11 @@ static mlir::Value emitExactDynamicCast(CIRGenItaniumCXXABI &abi,
   mlir::Type vptrPtrTy = builder.getPointerTo(vptrTy);
   Address srcVPtrPtr(builder.createBitcast(src.getPointer(), vptrPtrTy),
                      src.getAlignment());
-  mlir::Value srcVPtr = builder.createLoad(loc, srcVPtrPtr);
-
-  // TODO(cir): decorate SrcVPtr with TBAA info.
-  assert(!cir::MissingFeatures::tbaaVTablePtr());
+  cir::LoadOp srcVPtr = builder.createLoad(loc, srcVPtrPtr);
+  // Classic CodeGen only tags the load when it goes through GetVTablePtr.
+  if (!castToMostDerived)
----------------
xlauko wrote:

No test covers the untagged branch. Could tbaa-vptr.cpp add `struct H final : D, E` (both deriving from `A`) with `dynamic_cast<H *>(a)` from an `A *`? Classic emits a tagged load and then an untagged one, and the file already shares LLVM checks with the classic run.

https://github.com/llvm/llvm-project/pull/247722


More information about the cfe-commits mailing list