mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
to check for improperly nested '@_semantic' functions.
Add a missing @_semantics("array.init") in ArraySlice found by the
diagnostic.
Distinguish between array.init and array.init.empty.
Categorize the types of semantic functions by how they affect the
inliner and pass pipeline, and centralize this logic in
PerformanceInlinerUtils. The ultimate goal is to prevent inlining of
"Fundamental" @_semantics calls and @_effects calls until the late
pipeline where we can safely discard semantics. However, that requires
significant pipeline changes.
In the meantime, this change prevents the situation from getting worse
and makes the intention clear. However, it has no significant effect
on the pass pipeline and inliner.
20 lines
494 B
Swift
20 lines
494 B
Swift
// RUN: %target-swift-frontend -emit-sil -primary-file %s -o /dev/null -verify
|
|
|
|
@_semantics("array.append_contentsOf")
|
|
public func funcA() {
|
|
funcB() // expected-warning {{'@_semantics' function calls non-'@_semantics' function with nested '@_semantics' calls}}
|
|
}
|
|
|
|
func getInt() -> Int {
|
|
return 3
|
|
}
|
|
|
|
// Make sure funcB is not itself a trivial wrapper by calling getInt
|
|
// for funcC's argument.
|
|
func funcB() {
|
|
funcC(i: getInt())
|
|
}
|
|
|
|
@_semantics("array.mutate_unknown")
|
|
func funcC(i: Int) {}
|