[swift-evolution] Base types casting and hidden function calls in SWIFT

Félix Cloutier felixcca at gmail.com
Mon Mar 28 23:07:24 CDT 2016


How did you come to that conclusion? In Swift 2.1 (I'm late to update), with optimizations on, this function:

> func test() -> Double {
> 	return Double(arc4random())
> }


compiles to:

> define hidden double @_TF4test4testFT_Sd() #0 {
> entry:
>   %0 = tail call i32 @arc4random()
>   %1 = uitofp i32 %0 to double
>   ret double %1
> }

which has no allocation at all.

Félix


More information about the swift-evolution mailing list