Define critical SILInstruction and SILBasicBlock getters inline.

It makes no sense to operate on the block's instruction list without
also including SILBasicBlock.h anyway. Similarly, it doesn't make
sense to query the entry block without including SILFunction.h.

Now we can call these simple getters in critical-path loops assuming
they are as cheap as a load. I was avoiding calling these in critical
path code, which resulted in less readability and consistency across
the code base.
This commit is contained in:
Andrew Trick
2022-09-22 12:18:23 -07:00
parent bc37208a53
commit ecc4474095
4 changed files with 38 additions and 22 deletions

View File

@@ -1461,4 +1461,20 @@ private:
} // end llvm namespace
//===----------------------------------------------------------------------===//
// Inline SIL implementations
//===----------------------------------------------------------------------===//
namespace swift {
inline bool SILBasicBlock::isEntry() const {
return this == &*getParent()->begin();
}
inline SILModule &SILInstruction::getModule() const {
return getFunction()->getModule();
}
} // end swift namespace
#endif