Skip to content

Commit 857d699

Browse files
committed
Move BasicBlock::getTerminator definition to the header
This way it can be inlined to its caller. This method shows up in the profile and it is essentially a fancy getter. It would benefit from inlining into its callers. NFC.
1 parent 01bc5b7 commit 857d699

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

llvm/include/llvm/IR/BasicBlock.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,11 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
116116

117117
/// Returns the terminator instruction if the block is well formed or null
118118
/// if the block is not well formed.
119-
const Instruction *getTerminator() const LLVM_READONLY;
119+
const Instruction *getTerminator() const LLVM_READONLY {
120+
if (InstList.empty() || !InstList.back().isTerminator())
121+
return nullptr;
122+
return &InstList.back();
123+
}
120124
Instruction *getTerminator() {
121125
return const_cast<Instruction *>(
122126
static_cast<const BasicBlock *>(this)->getTerminator());

llvm/lib/IR/BasicBlock.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,6 @@ const Module *BasicBlock::getModule() const {
148148
return getParent()->getParent();
149149
}
150150

151-
const Instruction *BasicBlock::getTerminator() const {
152-
if (InstList.empty() || !InstList.back().isTerminator())
153-
return nullptr;
154-
return &InstList.back();
155-
}
156-
157151
const CallInst *BasicBlock::getTerminatingMustTailCall() const {
158152
if (InstList.empty())
159153
return nullptr;

0 commit comments

Comments
 (0)