Use llvm 13+'s [[musttail]] for dynapi #9229
Open
+203
−164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Suggested here as an attempt to reduce file sizes (#9206).
When building a 32-bit msys2 llvm15 toolchain, file size reductions are 10 kiB to nothing (a stripped executable is around 1.88MB)
[[musttail]]
requires an explicitreturn
, this pr introducesSDL_DYNAPI_PROC
for functions returning something andSDL_DYNAPI_PROC_VOID
for functions returning nothing. It also introducesSDL_DYNAPI_PROC_NO_TAILCALL
for explicitly disabling[[musttail]]
(see below why).gendynapi.py
has been modified to support these.__attribute__ ((musttail))
in appropriate locations inSDL_dynapi.c
.[[musttail]]
has been explicitly disabled for functions accepting aSDL_GUID
argument by value. Testautomation was segfaulting. I'm not entirely sure why this happens.Ironically, disabling
[[musttail]]
(forDSL_GUIDToString
) produces less code that works and code that uses a tail call.SDL_GUIDToString
, built with llvm's[[tailcall]]
(segfaults)SDL_GUIDToString
, build without llvm's[[tailcall]]
(works)FYI, llvm generates code that is peculiar:
Does anybody know why this happens? The
mov
's can be removed, can't they?I observe the same behavior in other SDL dynapi entry functions accepting an argument, and it is worse for functions accepting multiple arguments.
e.g.
Description
Existing Issue(s)