This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Increase coverage of shrink wrapping [5/5]
ClosedPublic

Authored by rafauler on May 20 2022, 8:25 PM.

Details

Summary

Add -experimental-shrink-wrapping flag to control when we
want to move callee-saved registers even when addresses of the stack
frame are captured and used in pointer arithmetic, making it more
challenging to do alias analysis to prove that we do not access
optimized stack positions. This alias analysis is not yet implemented,
hence, it is experimental. In practice, though, no compiler would emit
code to do pointer arithmetic to access a saved callee-saved register
unless there is a memory bug or we are failing to identify a
callee-saved reg, so I'm not sure how useful it would be to formally
prove that.

Diff Detail

Event Timeline

rafauler created this revision.May 20 2022, 8:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2022, 8:25 PM
Herald added a subscriber: pengfei. · View Herald Transcript
rafauler requested review of this revision.May 20 2022, 8:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 20 2022, 8:25 PM
Amir accepted this revision.Jun 14 2022, 9:24 PM

To recap:

  1. This diff adds a new experimental shrink wrapping mode which ignores escaping stack pointer (ie. mov rsp -> reg) in moving callee-saved registers.
  2. This is based on the assumption that stack frame locations for CSRs are not explicitly addressed by the function code.
  3. For functions that have been optimized under this mode, the new property (FAA.doesEscapeStackAddress) is added to prevent further Frame optimizations.
This revision is now accepted and ready to land.Jun 14 2022, 9:24 PM
This revision was automatically updated to reflect the committed changes.