diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2019-01-07 05:15:49 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2019-01-07 05:15:49 +0000 |
commit | f6f134e4d44ca8db242e168de6da7eb68e9cf76e (patch) | |
tree | 63cf832af693d1fb39f02bc5a5082dff1a4a2afa | |
parent | 7dda73a223c2c2bc48ba37f2cc3c1fd7b976c186 (diff) | |
download | bcm5719-llvm-f6f134e4d44ca8db242e168de6da7eb68e9cf76e.tar.gz bcm5719-llvm-f6f134e4d44ca8db242e168de6da7eb68e9cf76e.zip |
[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
llvm-svn: 350502
-rw-r--r-- | llvm/include/llvm/IR/InstVisitor.h | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/llvm/include/llvm/IR/InstVisitor.h b/llvm/include/llvm/IR/InstVisitor.h index 5e9b18d90a0..c5b4c6f71d7 100644 --- a/llvm/include/llvm/IR/InstVisitor.h +++ b/llvm/include/llvm/IR/InstVisitor.h @@ -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 |