]> granicus.if.org Git - llvm/commitdiff
[CallSite removal] Add `CallBase` support to the `InstVisitor` in such
authorChandler Carruth <chandlerc@gmail.com>
Mon, 7 Jan 2019 05:15:49 +0000 (05:15 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 7 Jan 2019 05:15:49 +0000 (05:15 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350502 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/InstVisitor.h

index 5e9b18d90a0cade0c32f7649472cfa21c73c91d6..c5b4c6f71d7d8e2be7aa2290723d01056158cea5 100644 (file)
@@ -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