[SR-7242] Usage of global constants to C functions generate suboptimal code (unless manually @convention(c)'d) #49790
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
performance
Attachment: Download
Additional Detail from JIRA
md5: d1766f8972c3d593ae26d61989363305
Issue Description:
For this code
I would expect the code generated for
System.writeViaConventionCGlobal
,System. writeViaNormalGlobal
andSystem.writeViaModule
to be identical. However, it's totally not:This is the command I run
which is
(today's 4.1 snapshot).
This is the assembly that comes out of this
First
System.writeViaModule
which is perfect. Then
System.writeViaConventionCGlobal
still almost perfect (but why isn't the constant propagated). But then
System.writeViaNormalGlobal
which is pretty terrible. It'll affect SwiftNIO ( https://github.com/apple/swift-nio/blob/master/Sources/NIO/System.swift#L34-L60 ) but I guess we can work around.
Unfortunately also just writing
gets you the suboptimal code, so the
@convention(c)
isn't inferred.The text was updated successfully, but these errors were encountered: