Files
swift-mirror/test/IRGen/builtin_conflict.sil
Yuta Saito 619226b480 Fix calling convention mismatch on Builtin.getCurrentAsyncTask (#37008)
* Add explicit calling convention on builtin GetCurrentTask

This builtin function emits a call of swift_task_getCurrent, and user
code can declare the same name function with slightly different
signature at LLVM level (data size should be same) using @_silgen_name.
In that case, IRGen insert cast inst to cast the function to the
expected signature. But this cast inst drops calling convention info, so
call inst was emitted without swiftcc.

This patch changed to emit a call of swift_task_getCurrent with the
explicit calling convention.

* Add test case to ensure builtin function cc when conflict
2021-04-23 09:35:37 +01:00

17 lines
670 B
Plaintext

// RUN: %target-swift-frontend -emit-ir -parse-sil %s -parse-stdlib | %FileCheck %s
import Builtin
import Swift
sil @entry : $@async @convention(thin) () -> () {
bb0:
%0 = function_ref @swift_task_getCurrent : $@convention(thin) () -> @owned Optional<Builtin.NativeObject>
// CHECK: call swiftcc {{.*}} @swift_task_getCurrent
%1 = apply %0() : $@convention(thin) () -> @owned Optional<Builtin.NativeObject>
// CHECK-NEXT: call swiftcc {{.*}} @swift_task_getCurrent
%3 = builtin "getCurrentAsyncTask"() : $Builtin.NativeObject
return undef : $()
}
sil hidden_external @swift_task_getCurrent : $@convention(thin) () -> @owned Optional<Builtin.NativeObject>