This is an archive of the discontinued LLVM Phabricator instance.

[SPARC] Don't do leaf optimization on procedures with inline assembly

Authored by koakuma on Jun 21 2022, 5:24 AM.



On SPARC, leaf function optimization omits the register window sliding (and the associated register name changes). This might result in miscompilation of procedures containing inline assembly, as some of the register constraints used may interfere with the register usage of optimized functions, so we disable leaf procedure optimization on those procedures to prevent it from happening.

This is a continuation of patch D102342 by @LemonBoy, the original comment is reproduced below:

Leaf functions allow the compiler to omit the setup and teardown of a frame pointer, therefore avoiding the exchange of the in/out register. According to the SPARC architecture manual every reference to %i0-%i5 should be replaced with %o0-o5, if the target register is already in use a further remapping step to %g1-%g7 is required to free the output register.

Add a simple check to make sure not to stomp on any output register that's already in use.

Diff Detail

Event Timeline

koakuma created this revision.Jun 21 2022, 5:24 AM
koakuma requested review of this revision.Jun 21 2022, 5:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2022, 5:24 AM
koakuma updated this revision to Diff 438679.Jun 21 2022, 6:42 AM

Also update other inline asm-related SPARC tests.

dcederman accepted this revision.Jun 27 2022, 5:46 AM
This revision is now accepted and ready to land.Jun 27 2022, 5:46 AM
This revision was landed with ongoing or failed builds.Jun 27 2022, 6:10 AM
This revision was automatically updated to reflect the committed changes.