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:
Arnold Schwaighofer
2014-08-19 18:05:44 +00:00
parent 88372515bd
commit 7aa62ce835
20 changed files with 113 additions and 23 deletions

View File

@@ -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)