mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* access * accessed * accesses * accessor * acquiring * across * activated * additive * address * addresses' * aggregated * analysis * and * appropriately * archetype * argument * associated * availability * barriers * because * been * beginning * belongs * beneficial * blocks * borrow * builtin * cannot * canonical * canonicalize * clazz * cleanup * coalesceable * coalesced * comparisons * completely * component * computed * concrete * conjunction * conservatively * constituent * construct * consuming * containing * covered * creates * critical * dataflow * declaration * defined * defining * definition * deinitialization * deliberately * dependencies * dependent * deserialized * destroy * deterministic * deterministically * devirtualizes * diagnostic * diagnostics * differentiation * disable * discipline * dominate * dominates * don't * element * eliminate * eliminating * elimination * embedded * encounter * epilogue * epsilon * escape * escaping * essential * evaluating * evaluation * evaluator * executing * existential * existentials * explicit * expression * extended * extension * extract * for * from * function * generic * guarantee * guaranteed * happened * heuristic * however * identifiable * immediately * implementation * improper * include * infinite * initialize * initialized * initializer * inside * instruction * interference * interferes * interleaved * internal * intersection * intractable * intrinsic * invalidates * irreducible * irrelevant * language * lifetime * literal * looks * materialize * meaning * mergeable * might * mimics * modification * modifies * multiple * mutating * necessarily * necessary * needsmultiplecopies * nonetheless * nothing * occurred * occurs * optimization * optimizing * original * outside * overflow * overlapping * overridden * owned * ownership * parallel * parameter * paths * patterns * pipeline * plottable * possible * potentially * practically * preamble * precede * preceding * predecessor * preferable * preparation * probably * projection * properties * property * protocol * reabstraction * reachable * recognized * recursive * recursively * redundant * reentrancy * referenced * registry * reinitialization * reload * represent * requires * response * responsible * retrieving * returned * returning * returns * rewriting * rewritten * sample * scenarios * scope * should * sideeffects * similar * simplify * simplifycfg * somewhat * spaghetti * specialization * specializations * specialized * specially * statistically * substitute * substitution * succeeds * successful * successfully * successor * superfluous * surprisingly * suspension * swift * targeted * that * that our * the * therefore * this * those * threshold * through * transform * transformation * truncated * ultimate * unchecked * uninitialized * unlikely * unmanaged * unoptimized key * updataflow * usefulness * utilities * villain * whenever * writes Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
77 lines
2.2 KiB
Swift
77 lines
2.2 KiB
Swift
// RUN: %target-swift-frontend -O -Xllvm -sil-inline-generics=false -Xllvm -sil-disable-pass=ObjectOutliner %s -emit-sil -sil-verify-all | %FileCheck %s
|
|
|
|
// Make sure that we completely inline/devirtualize/substitute all the way down
|
|
// to unknown1.
|
|
|
|
// CHECK-LABEL: sil {{.*}}@main
|
|
// CHECK: bb0({{.*}}):
|
|
// CHECK: function_ref @unknown1
|
|
// CHECK: apply
|
|
// CHECK: apply
|
|
// CHECK: return
|
|
|
|
struct Int32 {}
|
|
|
|
@_silgen_name("unknown1")
|
|
func unknown1() -> ()
|
|
|
|
protocol P {
|
|
func doSomething(_ x : Int32)
|
|
}
|
|
|
|
struct X {}
|
|
|
|
class B<T> : P {
|
|
func doSomething(_ x : Int32) {
|
|
unknown1()
|
|
}
|
|
}
|
|
|
|
func doSomething(_ p : P, _ x : Int32) {
|
|
p.doSomething(x)
|
|
}
|
|
func doSomething2<T : P>(_ t : T, _ x : Int32) {
|
|
t.doSomething(x)
|
|
}
|
|
|
|
func driver() {
|
|
var b2 = B<X>()
|
|
var x = Int32()
|
|
doSomething(b2, x)
|
|
doSomething2(b2, x)
|
|
}
|
|
|
|
driver()
|
|
|
|
// <rdar://problem/46322928> Failure to devirtualize a protocol method
|
|
// applied to an opened existential blocks implementation of
|
|
// DataProtocol.
|
|
public protocol ContiguousBytes {
|
|
func withUnsafeBytes<R>(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R
|
|
}
|
|
|
|
extension Array : ContiguousBytes {}
|
|
extension ContiguousArray : ContiguousBytes {}
|
|
|
|
@inline(never)
|
|
func takesPointer(_ p: UnsafeRawBufferPointer) {}
|
|
|
|
// In specialized testWithUnsafeBytes<A>(_:), the conditional case and call to withUnsafeBytes must be eliminated.
|
|
// Normally, we expect Array.withUnsafeBytes to be inlined so we would see:
|
|
// [[TAKES_PTR:%.*]] = function_ref @$s30devirt_specialized_conformance12takesPointeryySWF : $@convention(thin) (UnsafeRawBufferPointer) -> ()
|
|
// apply [[TAKES_PTR]](%{{.*}}) : $@convention(thin) (UnsafeRawBufferPointer) -> ()
|
|
// But the inlining isn't consistent across builds with and without debug info.
|
|
//
|
|
// CHECK-LABEL: sil shared [noinline] @$s30devirt_specialized_conformance19testWithUnsafeBytesyyxlFSayypG_Tg5 : $@convention(thin) (@guaranteed Array<Any>) -> () {
|
|
// CHECK: bb0
|
|
// CHECK-NOT: witness_method
|
|
// CHECK-LABEL: } // end sil function '$s30devirt_specialized_conformance19testWithUnsafeBytesyyxlFSayypG_Tg5'
|
|
@inline(never)
|
|
func testWithUnsafeBytes<T>(_ t: T) {
|
|
if let cb = t as? ContiguousBytes {
|
|
cb.withUnsafeBytes { takesPointer($0) }
|
|
}
|
|
}
|
|
|
|
testWithUnsafeBytes([])
|