[clang] [IRPGO][ValueProfile] Instrument virtual table address that could be used to do virtual table address comparision for indirect-call-promotion. (PR #66825)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 5 16:22:03 PDT 2023


================
@@ -19,20 +19,38 @@ namespace llvm {
 // Visitor class that finds all indirect call.
 struct PGOIndirectCallVisitor : public InstVisitor<PGOIndirectCallVisitor> {
   std::vector<CallBase *> IndirectCalls;
+  std::vector<Instruction *> VTableAddrs;
   PGOIndirectCallVisitor() = default;
 
   void visitCallBase(CallBase &Call) {
     if (Call.isIndirectCall())
-      IndirectCalls.push_back(&Call);
+      if (Call.isIndirectCall()) {
+        IndirectCalls.push_back(&Call);
+
+        LoadInst *LI = dyn_cast<LoadInst>(Call.getCalledOperand());
----------------
modiking wrote:

True, detection would need to be done in Clang. Maybe a better way to think about/document this is that this particular feature of IRPGO is enabled when `-fwhole-program-vtables` is enabled and otherwise disabled. The backend flag can still exist but more as an opt-out option.

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


More information about the cfe-commits mailing list