[llvm] r350502 - [CallSite removal] Add `CallBase` support to the `InstVisitor` in such

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 6 21:15:49 PST 2019


Author: chandlerc
Date: Sun Jan  6 21:15:49 2019
New Revision: 350502

URL: http://llvm.org/viewvc/llvm-project?rev=350502&view=rev
Log:
[CallSite removal] Add `CallBase` support to the `InstVisitor` in such
a way that it still supports `CallSite` but users can be ported to rely
on `CallBase` instead.

This will unblock the ports across the analysis and transforms libraries
(and out-of-tree users) and once done we can clean this up by removing
the `CallSite` layer.

Differential Revision: https://reviews.llvm.org/D56182

Modified:
    llvm/trunk/include/llvm/IR/InstVisitor.h

Modified: llvm/trunk/include/llvm/IR/InstVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/InstVisitor.h?rev=350502&r1=350501&r2=350502&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/InstVisitor.h (original)
+++ llvm/trunk/include/llvm/IR/InstVisitor.h Sun Jan  6 21:15:49 2019
@@ -268,17 +268,23 @@ public:
   RetTy visitCmpInst(CmpInst &I)                  { DELEGATE(Instruction);}
   RetTy visitUnaryInstruction(UnaryInstruction &I){ DELEGATE(Instruction);}
 
-  // Provide a special visitor for a 'callsite' that visits both calls and
-  // invokes. When unimplemented, properly delegates to either the terminator or
-  // regular instruction visitor.
+  // The next level delegation for `CallBase` is slightly more complex in order
+  // to support visiting cases where the call is also a terminator.
+  RetTy visitCallBase(CallBase &I) {
+    if (isa<InvokeInst>(I))
+      return static_cast<SubClass *>(this)->visitTerminator(I);
+
+    DELEGATE(Instruction);
+  }
+
+  // Provide a legacy visitor for a 'callsite' that visits both calls and
+  // invokes.
+  //
+  // Prefer overriding the type system based `CallBase` instead.
   RetTy visitCallSite(CallSite CS) {
     assert(CS);
     Instruction &I = *CS.getInstruction();
-    if (CS.isCall())
-      DELEGATE(Instruction);
-
-    assert(CS.isInvoke());
-    return static_cast<SubClass *>(this)->visitTerminator(I);
+    DELEGATE(CallBase);
   }
 
   // If the user wants a 'default' case, they can choose to override this




More information about the llvm-commits mailing list