[clang] [llvm] [ThinLTO] Support dead RTTI data elimination under -fno-split-lto-unit (PR #126336)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 12 11:01:50 PST 2025


================
@@ -50,6 +51,42 @@ findCallsAtConstantOffset(SmallVectorImpl<DevirtCallSite> &DevirtCalls,
   }
 }
 
+static bool hasTypeIdLoadAtConstantOffset(const Module *M, Value *VPtr,
+                                          int64_t Offset, const CallInst *CI,
+                                          CXXABI *ABI) {
+  Triple TT(M->getTargetTriple());
+  bool HasTypeIdLoad = false;
+  for (const Use &U : VPtr->uses()) {
+    Value *User = U.getUser();
+    if (isa<BitCastInst>(User)) {
+      HasTypeIdLoad |= hasTypeIdLoadAtConstantOffset(M, User, Offset, CI, ABI);
+    } else if (isa<LoadInst>(User)) {
+      if (Offset ==
+          ABI->getOffsetFromTypeInfoSlotToAddressPoint(M->getDataLayout()))
----------------
teresajohnson wrote:

For WPD and CFI this the information about type tests and the vtable address points are correlated from the summary during the thin link. Can we do that for this optimization as well so that we don't need to put info about the ABI in LLVM? E.g. see how we summarize the potential virtual calls for each type test. Alternatively, since the presence of a possible type id load results in conservative behavior, we may not even need to know the exact offset in this analysis.

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


More information about the llvm-commits mailing list