summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instructions.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-06-08 23:23:08 +0000
committerCraig Topper <craig.topper@gmail.com>2017-06-08 23:23:08 +0000
commitc1993fa1a3ec2e9c9722879ea9cb80d9a3cacce2 (patch)
tree743a3b5c18880bc863e2ca1771211270bc5a46e9 /llvm/lib/IR/Instructions.cpp
parente357fbd24381d03238e2f4487fd7ff3acfc53b19 (diff)
downloadbcm5719-llvm-c1993fa1a3ec2e9c9722879ea9cb80d9a3cacce2.tar.gz
bcm5719-llvm-c1993fa1a3ec2e9c9722879ea9cb80d9a3cacce2.zip
[IR] Remove getNumSuccessorsV/getSuccessorV/setSuccessorV from the TerminatorInst subclasses as much as possible now that Value has been de-virtualized
These used to be virtual methods that would enable doing the right thing with only a TerminatorInst pointer. I believe they were also acting as vtable anchors in my cases. I think the fact that they had a separate name ending in V was to allow a version without V to be called without a virtual call in a pre-C++11 final keyword world. Where possible the base methods in TerminatorInst dispatch directly to the public methods in the classes that have the same signature. For some classes this wasn't possible so I've left private method versions that match the name and signature of the version in TerminatorInst. All versions have been moved into the class definitions since we no longer need vtable anchors here. Differential Revision: https://reviews.llvm.org/D34011 llvm-svn: 305028
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r--llvm/lib/IR/Instructions.cpp133
1 files changed, 3 insertions, 130 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 0677ba285e9..023a0b178a1 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -63,7 +63,7 @@ unsigned TerminatorInst::getNumSuccessors() const {
switch (getOpcode()) {
#define HANDLE_TERM_INST(N, OPC, CLASS) \
case Instruction::OPC: \
- return static_cast<const CLASS *>(this)->getNumSuccessorsV();
+ return static_cast<const CLASS *>(this)->getNumSuccessors();
#include "llvm/IR/Instruction.def"
default:
break;
@@ -75,7 +75,7 @@ BasicBlock *TerminatorInst::getSuccessor(unsigned idx) const {
switch (getOpcode()) {
#define HANDLE_TERM_INST(N, OPC, CLASS) \
case Instruction::OPC: \
- return static_cast<const CLASS *>(this)->getSuccessorV(idx);
+ return static_cast<const CLASS *>(this)->getSuccessor(idx);
#include "llvm/IR/Instruction.def"
default:
break;
@@ -87,7 +87,7 @@ void TerminatorInst::setSuccessor(unsigned idx, BasicBlock *B) {
switch (getOpcode()) {
#define HANDLE_TERM_INST(N, OPC, CLASS) \
case Instruction::OPC: \
- return static_cast<CLASS *>(this)->setSuccessorV(idx, B);
+ return static_cast<CLASS *>(this)->setSuccessor(idx, B);
#include "llvm/IR/Instruction.def"
default:
break;
@@ -747,18 +747,6 @@ InvokeInst *InvokeInst::Create(InvokeInst *II, ArrayRef<OperandBundleDef> OpB,
return NewII;
}
-BasicBlock *InvokeInst::getSuccessorV(unsigned idx) const {
- return getSuccessor(idx);
-}
-
-unsigned InvokeInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void InvokeInst::setSuccessorV(unsigned idx, BasicBlock *B) {
- return setSuccessor(idx, B);
-}
-
Value *InvokeInst::getReturnedArgOperand() const {
unsigned Index;
@@ -902,20 +890,6 @@ ReturnInst::ReturnInst(LLVMContext &Context, BasicBlock *InsertAtEnd)
OperandTraits<ReturnInst>::op_end(this), 0, InsertAtEnd) {
}
-unsigned ReturnInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-/// Out-of-line ReturnInst method, put here so the C++ compiler can choose to
-/// emit the vtable for the class in this translation unit.
-void ReturnInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) {
- llvm_unreachable("ReturnInst has no successors!");
-}
-
-BasicBlock *ReturnInst::getSuccessorV(unsigned idx) const {
- llvm_unreachable("ReturnInst has no successors!");
-}
-
//===----------------------------------------------------------------------===//
// ResumeInst Implementation
//===----------------------------------------------------------------------===//
@@ -938,18 +912,6 @@ ResumeInst::ResumeInst(Value *Exn, BasicBlock *InsertAtEnd)
Op<0>() = Exn;
}
-unsigned ResumeInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void ResumeInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) {
- llvm_unreachable("ResumeInst has no successors!");
-}
-
-BasicBlock *ResumeInst::getSuccessorV(unsigned idx) const {
- llvm_unreachable("ResumeInst has no successors!");
-}
-
//===----------------------------------------------------------------------===//
// CleanupReturnInst Implementation
//===----------------------------------------------------------------------===//
@@ -992,20 +954,6 @@ CleanupReturnInst::CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB,
init(CleanupPad, UnwindBB);
}
-BasicBlock *CleanupReturnInst::getSuccessorV(unsigned Idx) const {
- assert(Idx == 0);
- return getUnwindDest();
-}
-
-unsigned CleanupReturnInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void CleanupReturnInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
- assert(Idx == 0);
- setUnwindDest(B);
-}
-
//===----------------------------------------------------------------------===//
// CatchReturnInst Implementation
//===----------------------------------------------------------------------===//
@@ -1037,20 +985,6 @@ CatchReturnInst::CatchReturnInst(Value *CatchPad, BasicBlock *BB,
init(CatchPad, BB);
}
-BasicBlock *CatchReturnInst::getSuccessorV(unsigned Idx) const {
- assert(Idx < getNumSuccessors() && "Successor # out of range for catchret!");
- return getSuccessor();
-}
-
-unsigned CatchReturnInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void CatchReturnInst::setSuccessorV(unsigned Idx, BasicBlock *B) {
- assert(Idx < getNumSuccessors() && "Successor # out of range for catchret!");
- setSuccessor(B);
-}
-
//===----------------------------------------------------------------------===//
// CatchSwitchInst Implementation
//===----------------------------------------------------------------------===//
@@ -1134,18 +1068,6 @@ void CatchSwitchInst::removeHandler(handler_iterator HI) {
setNumHungOffUseOperands(getNumOperands() - 1);
}
-BasicBlock *CatchSwitchInst::getSuccessorV(unsigned idx) const {
- return getSuccessor(idx);
-}
-
-unsigned CatchSwitchInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void CatchSwitchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
- setSuccessor(idx, B);
-}
-
//===----------------------------------------------------------------------===//
// FuncletPadInst Implementation
//===----------------------------------------------------------------------===//
@@ -1198,18 +1120,6 @@ UnreachableInst::UnreachableInst(LLVMContext &Context, BasicBlock *InsertAtEnd)
nullptr, 0, InsertAtEnd) {
}
-unsigned UnreachableInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void UnreachableInst::setSuccessorV(unsigned idx, BasicBlock *NewSucc) {
- llvm_unreachable("UnreachableInst has no successors!");
-}
-
-BasicBlock *UnreachableInst::getSuccessorV(unsigned idx) const {
- llvm_unreachable("UnreachableInst has no successors!");
-}
-
//===----------------------------------------------------------------------===//
// BranchInst Implementation
//===----------------------------------------------------------------------===//
@@ -1285,18 +1195,6 @@ void BranchInst::swapSuccessors() {
swapProfMetadata();
}
-BasicBlock *BranchInst::getSuccessorV(unsigned idx) const {
- return getSuccessor(idx);
-}
-
-unsigned BranchInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void BranchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
- setSuccessor(idx, B);
-}
-
//===----------------------------------------------------------------------===//
// AllocaInst Implementation
//===----------------------------------------------------------------------===//
@@ -3785,19 +3683,6 @@ void SwitchInst::growOperands() {
growHungoffUses(ReservedSpace);
}
-
-BasicBlock *SwitchInst::getSuccessorV(unsigned idx) const {
- return getSuccessor(idx);
-}
-
-unsigned SwitchInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void SwitchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
- setSuccessor(idx, B);
-}
-
//===----------------------------------------------------------------------===//
// IndirectBrInst Implementation
//===----------------------------------------------------------------------===//
@@ -3877,18 +3762,6 @@ void IndirectBrInst::removeDestination(unsigned idx) {
setNumHungOffUseOperands(NumOps-1);
}
-BasicBlock *IndirectBrInst::getSuccessorV(unsigned idx) const {
- return getSuccessor(idx);
-}
-
-unsigned IndirectBrInst::getNumSuccessorsV() const {
- return getNumSuccessors();
-}
-
-void IndirectBrInst::setSuccessorV(unsigned idx, BasicBlock *B) {
- setSuccessor(idx, B);
-}
-
//===----------------------------------------------------------------------===//
// cloneImpl() implementations
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud