[llvm] [TypeProf][PGO]Support skipping vtable comparisons for a class and its derived ones (PR #110575)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 1 22:26:09 PDT 2024


================
@@ -851,8 +863,25 @@ bool IndirectCallPromoter::isProfitableToCompareVTables(
     LLVM_DEBUG(dbgs() << "\n");
 
     uint64_t CandidateVTableCount = 0;
-    for (auto &[GUID, Count] : VTableGUIDAndCounts)
+
+    for (auto &[GUID, Count] : VTableGUIDAndCounts) {
       CandidateVTableCount += Count;
+      auto *VTableVar = Symtab->getGlobalVariable(GUID);
+
+      assert(VTableVar &&
+             "VTableVar must exist for GUID in VTableGUIDAndCounts");
+
+      SmallVector<MDNode *, 2> Types;
+      VTableVar->getMetadata(LLVMContext::MD_type, Types);
+
+      for (auto *Type : Types)
+        if (auto *TypeId = dyn_cast<MDString>(Type->getOperand(1).get()))
+          if (IgnoredBaseTypes.contains(TypeId->getString())) {
+            LLVM_DEBUG(dbgs() << "    vtable profiles should be ignored. Bail "
+                                 "out vtable comparison.");
----------------
minglotus-6 wrote:

done.

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


More information about the llvm-commits mailing list