Skip to content

Commit c52e3b9

Browse files
authored
Merge pull request #61288 from atrick/inline-sil-getters
Define critical SILInstruction and SILBasicBlock getters inline.
2 parents 2f5492f + ecc4474 commit c52e3b9

File tree

4 files changed

+38
-22
lines changed

4 files changed

+38
-22
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,4 +659,26 @@ template <> struct DenseMapInfo<swift::PhiValue> {
659659

660660
} // end namespace llvm
661661

662+
//===----------------------------------------------------------------------===//
663+
// Inline SILInstruction implementations
664+
//===----------------------------------------------------------------------===//
665+
666+
namespace swift {
667+
668+
inline SILFunction *SILInstruction::getFunction() const {
669+
return getParent()->getParent();
670+
}
671+
672+
inline SILInstruction *SILInstruction::getPreviousInstruction() {
673+
auto pos = getIterator();
674+
return pos == getParent()->begin() ? nullptr : &*std::prev(pos);
675+
}
676+
677+
inline SILInstruction *SILInstruction::getNextInstruction() {
678+
auto nextPos = std::next(getIterator());
679+
return nextPos == getParent()->end() ? nullptr : &*nextPos;
680+
}
681+
682+
} // end swift namespace
683+
662684
#endif

include/swift/SIL/SILFunction.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,4 +1461,20 @@ public ilist_node_traits<::swift::SILFunction> {
14611461

14621462
} // end llvm namespace
14631463

1464+
//===----------------------------------------------------------------------===//
1465+
// Inline SIL implementations
1466+
//===----------------------------------------------------------------------===//
1467+
1468+
namespace swift {
1469+
1470+
inline bool SILBasicBlock::isEntry() const {
1471+
return this == &*getParent()->begin();
1472+
}
1473+
1474+
inline SILModule &SILInstruction::getModule() const {
1475+
return getFunction()->getModule();
1476+
}
1477+
1478+
} // end swift namespace
1479+
14641480
#endif

lib/SIL/IR/SILBasicBlock.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,6 @@ ScopeCloner::getOrCreateClonedScope(const SILDebugScope *OrigScope) {
361361
return ClonedScope;
362362
}
363363

364-
bool SILBasicBlock::isEntry() const {
365-
return this == &*getParent()->begin();
366-
}
367-
368364
/// Declared out of line so we can have a declaration of SILArgument.
369365
#define ARGUMENT(NAME, PARENT) \
370366
NAME##ArrayRef SILBasicBlock::get##NAME##s() const { \

lib/SIL/IR/SILInstruction.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,6 @@ transferNodesFromList(llvm::ilist_traits<SILInstruction> &L2,
104104
ASSERT_IMPLEMENTS_STATIC(CLASS, PARENT, classof, bool(SILNodePointer));
105105
#include "swift/SIL/SILNodes.def"
106106

107-
SILFunction *SILInstruction::getFunction() const {
108-
return getParent()->getParent();
109-
}
110-
111-
SILModule &SILInstruction::getModule() const {
112-
return getFunction()->getModule();
113-
}
114-
115-
SILInstruction *SILInstruction::getPreviousInstruction() {
116-
auto pos = getIterator();
117-
return pos == getParent()->begin() ? nullptr : &*std::prev(pos);
118-
}
119-
120-
SILInstruction *SILInstruction::getNextInstruction() {
121-
auto nextPos = std::next(getIterator());
122-
return nextPos == getParent()->end() ? nullptr : &*nextPos;
123-
}
124-
125107
void SILInstruction::removeFromParent() {
126108
#ifndef NDEBUG
127109
for (auto result : getResults()) {

0 commit comments

Comments
 (0)