mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The intent for `@inline(always)` is to act as an optimization control. The user can rely on inlining to happen or the compiler will emit an error message. Because function values can be dynamic (closures, protocol/class lookup) this guarantee can only be upheld for direct function references. In cases where the optimizer can resolve dynamic function values the attribute shall be respected. rdar://148608854
27 lines
1.3 KiB
Plaintext
27 lines
1.3 KiB
Plaintext
// RUN: %target-sil-opt -enable-sil-verify-all %s -inline-always-inlining -verify
|
|
|
|
import Builtin
|
|
import Swift
|
|
|
|
sil [always_inline] @test_circular_foo : $@convention(thin) (Float32) -> Float32 {
|
|
bb0(%0 : $Float32):
|
|
%3 = function_ref @test_circular_bar : $@convention(thin) (Float32) -> Float32
|
|
%5 = apply %3(%0) : $@convention(thin) (Float32) -> Float32 // expected-error {{inlining '@inline(always)' functions forms circular loop}} expected-note 2 {{while inlining here}}
|
|
return %5 : $Float32
|
|
}
|
|
|
|
sil [always_inline] @test_circular_bar : $@convention(thin) (Float32) -> Float32 {
|
|
bb0(%0 : $Float32):
|
|
%3 = function_ref @test_circular_baz : $@convention(thin) (Float32) -> Float32
|
|
%5 = apply %3(%0) : $@convention(thin) (Float32) -> Float32 // expected-error {{inlining '@inline(always)' functions forms circular loop}} expected-note 2 {{while inlining here}}
|
|
return %5 : $Float32
|
|
}
|
|
|
|
sil [always_inline] @test_circular_baz : $@convention(thin) (Float32) -> Float32 {
|
|
bb0(%0 : $Float32):
|
|
%3 = function_ref @test_circular_foo : $@convention(thin) (Float32) -> Float32
|
|
%5 = apply %3(%0) : $@convention(thin) (Float32) -> Float32 // expected-error {{inlining '@inline(always)' functions forms circular loop}} expected-note 2 {{while inlining here}}
|
|
return %5 : $Float32
|
|
}
|
|
|