This is an archive of the discontinued LLVM Phabricator instance.

[Sparc] Flush register windows for @llvm.returnaddress(1)
ClosedPublic

Authored by dcederman on Jun 27 2018, 5:21 AM.

Details

Summary

When @llvm.returnaddress is called with a value higher than 0 it needs to read from the call stack to get the return address. This means that the register windows needs to be flushed to the stack to guarantee that the data read is valid. For values higher than 1 this is done indirectly by the call to getFRAMEADDR(), but not for the value 1.

Diff Detail

Repository
rL LLVM

Event Timeline

dcederman created this revision.Jun 27 2018, 5:21 AM
jyknight added inline comments.Jul 13 2018, 11:38 AM
lib/Target/Sparc/SparcISelLowering.cpp
2733 ↗(On Diff #153051)

Maybe pull FLUSHW out of getFRAMEADDR, into LowerFRAMEADDR, so it doesn't get emitted twice here for returnaddress(>= 2) calls?

dcederman updated this revision to Diff 160364.Aug 13 2018, 8:44 AM

Added optional argument to getFRAMEADDR to always flush register windows regardless of depth. Also simplified the code a bit.

jyknight accepted this revision.Aug 15 2018, 11:59 AM
This revision is now accepted and ready to land.Aug 15 2018, 11:59 AM
This revision was automatically updated to reflect the committed changes.