Skip to content

Enable the inlining of generics by default #7660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Transforms/PerformanceInliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ llvm::cl::opt<bool> PrintShortestPathInfo(
llvm::cl::desc("Print shortest-path information for inlining"));

llvm::cl::opt<bool> EnableSILInliningOfGenerics(
"sil-inline-generics", llvm::cl::init(false),
"sil-inline-generics", llvm::cl::init(true),
llvm::cl::desc("Enable inlining of generics"));

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion test/SILGen/collection_cast_crash.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -O -primary-file %s -emit-sil -o - | %FileCheck %s
// RUN: %target-swift-frontend -O -Xllvm -sil-inline-generics=false -primary-file %s -emit-sil -o - | %FileCheck %s

// check if the compiler does not crash if a function is specialized
// which contains a collection cast
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/devirt_covariant_return.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -Xllvm -new-mangling-for-tests -Xllvm -sil-full-demangle -O -Xllvm -disable-sil-cm-rr-cm=0 -primary-file %s -emit-sil -sil-inline-threshold 1000 -sil-verify-all | %FileCheck %s
// RUN: %target-swift-frontend -Xllvm -new-mangling-for-tests -Xllvm -sil-full-demangle -O -Xllvm -disable-sil-cm-rr-cm=0 -Xllvm -sil-inline-generics=false -primary-file %s -emit-sil -sil-inline-threshold 1000 -sil-verify-all | %FileCheck %s

// Make sure that we can dig all the way through the class hierarchy and
// protocol conformances with covariant return types correctly. The verifier
Expand Down
2 changes: 2 additions & 0 deletions test/SILOptimizer/devirt_protocol_method_invocations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@ protocol MathP {
}

extension MathP {
@inline(never)
func plus() -> Self {
sum += 1
return self
}

@inline(never)
func minus() {
sum -= 1
if sum == 0 {
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/devirt_specialized_conformance.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend -O %s -emit-sil -sil-verify-all | %FileCheck %s
// RUN: %target-swift-frontend -O -Xllvm -sil-inline-generics=false %s -emit-sil -sil-verify-all | %FileCheck %s

// Make sure that we completely inline/devirtualize/substitute all the way down
// to unknown1.
Expand Down
10 changes: 6 additions & 4 deletions test/SILOptimizer/devirt_unbound_generic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class Derived<T> : Base<T> {
// Derived has no subclasses and it is a WMO compilation.
// CHECK: sil hidden [noinline] @_T022devirt_unbound_generic5test2yAA7DerivedCyxGlF
// CHECK-NOT: class_method
// CHECK: function_ref @_T022devirt_unbound_generic7DerivedC3fooyyF
// CHECK-NOT: class_method
// CHECK-NOT: witness_method
// CHECK-NOT: apply
// CHECK: return
// CHEC: end sil function '_T022devirt_unbound_generic5test2yAA7DerivedCyxGlF'
@inline(never)
func test2<T>(_ d: Derived<T>) {
d.foo()
Expand All @@ -62,9 +63,10 @@ public func doTest2<T>(_ t:T) {
// Derived has no subclasses and it is a WMO compilation.
// CHECK: sil hidden [noinline] @_T022devirt_unbound_generic5test3yAA7DerivedCyxGlF
// CHECK-NOT: class_method
// CHECK: function_ref @_T022devirt_unbound_generic7DerivedC3booyyFZ
// CHECK-NOT: class_method
// CHECK-NOT: witness_method
// CHECK-NOT: apply
// CHECK: return
// CHECK: end sil function '_T022devirt_unbound_generic5test3yAA7DerivedCyxGlF'
@inline(never)
func test3<T>(_ d: Derived<T>) {
type(of: d).boo()
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/opened_archetype_operands_tracking.sil
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension P {

public func process(s: P)

sil @invokeClosure : $@convention(method) <Self where Self : P> (@owned @callee_owned () -> @error Error, @in_guaranteed Self) -> @error Error {
sil [noinline] @invokeClosure : $@convention(method) <Self where Self : P> (@owned @callee_owned () -> @error Error, @in_guaranteed Self) -> @error Error {
bb0(%0 : $@callee_owned () -> @error Error, %1 : $*Self):
strong_release %0 : $@callee_owned () -> @error Error
%5 = tuple ()
Expand Down
4 changes: 2 additions & 2 deletions test/SILOptimizer/prespecialize.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend %s -Onone -emit-sil | %FileCheck %s
// RUN: %target-swift-frontend %s -Onone -Xllvm -sil-inline-generics=false -emit-sil | %FileCheck %s

// REQUIRES: optimized_stdlib

Expand All @@ -11,7 +11,7 @@
// CHECK-LABEL: sil [noinline] @_TF13prespecialize4testFTRGSaSi_4sizeSi_T_
//
// function_ref specialized Collection<A where ...>.makeIterator() -> IndexingIterator<A>
// CHECK: function_ref @_TTSgq5SiSis10ComparablesSis11_Strideables___TFVs14CountableRangeCfT15uncheckedBoundsT5lowerx5upperx__GS_x_
// CHECK: function_ref @_TTSgq5GVs14CountableRangeSi_GS_Si_s10Collections___TFesRxs10Collectionwx8IteratorzGVs16IndexingIteratorx_rS_12makeIteratorfT_GS1_x_
//
// function_ref specialized IndexingIterator.next() -> A._Element?
// CHECK: function_ref @_TTSgq5GVs14CountableRangeSi_GS_Si_s14_IndexableBases___TFVs16IndexingIterator4nextfT_GSqwx8_Element_
Expand Down