mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add an inline(late) attribute
This disables inlining at the SIL level. LLVM inlining is still enabled. We can
use this to expose one function at the SIL level - which can participate in
dominance based optimizations but which is implemented in terms of a cheap check
and an expensive check (function call) that benefits from LLVM's inlining.
Example:
The inline(late) in the example below prevents inlining of the two checks. We
can now perform dominance based optimizations on isClassOrObjExistential.
Without blocking inlining the optimizations would apply to the sizeof check
only and we would have multiple expensive function calls.
@inline(late)
func isClassOrObjExistential(t: Type) -> Bool{
return sizeof(t) == sizeof(AnyObject) &&
swift_isClassOrObjExistential(t)
}
We do want inlining of this function to happen at the LLVM level because the
first check is constant folded away - IRGen replaces sizeof by constants.
rdar://17961249
Swift SVN r21286
This commit is contained in:
@@ -30,7 +30,7 @@ SILFunction *SILFunction::create(SILModule &M, SILLinkage linkage,
|
||||
Optional<SILLocation> loc,
|
||||
IsBare_t isBareSILFunction,
|
||||
IsTransparent_t isTrans,
|
||||
bool isNoinline, EffectsKind E,
|
||||
Inline_t isNoinline, EffectsKind E,
|
||||
SILFunction *insertBefore,
|
||||
SILDebugScope *debugScope,
|
||||
DeclContext *DC) {
|
||||
@@ -58,7 +58,7 @@ SILFunction::SILFunction(SILModule &Module, SILLinkage Linkage,
|
||||
Optional<SILLocation> Loc,
|
||||
IsBare_t isBareSILFunction,
|
||||
IsTransparent_t isTrans,
|
||||
bool isNoinline, EffectsKind E,
|
||||
Inline_t isNoinline, EffectsKind E,
|
||||
SILFunction *InsertBefore,
|
||||
SILDebugScope *DebugScope,
|
||||
DeclContext *DC)
|
||||
|
||||
Reference in New Issue
Block a user