This is an archive of the discontinued LLVM Phabricator instance.

[ipra] Fix missing save/restore of function return addresses
Needs RevisionPublic

Authored by cme on Sep 5 2022, 6:34 AM.

Details

Summary

This patch adds the architecture-neutral components of a fix for issue #57482 ( https://github.com/llvm/llvm-project/issues/57482 ), and the artitecture-specific parts of the fix for MIPS processors.

IPRA allows the save/restore sequences to be omitted from callees whose clobber sets have been fully accounted for by the calling function due to IPRA. However, since the return address to return from the callee is used in the *return* instruction of the calling instruction rather than in the caller, having the caller preserve a value is inadequate for return addresses.

No existing register property available in the framework encapsulates this "needed for return instruction" property, so this changed adds this as a TargerRegisterInfo query method.

Diff Detail

Event Timeline

cme created this revision.Sep 5 2022, 6:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2022, 6:34 AM
cme requested review of this revision.Sep 5 2022, 6:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2022, 6:34 AM

I haven't touched this part of the project for multiple years, I'm not sure I'll be the best person to review.

cme added a comment.Sep 5 2022, 7:36 AM

I haven't touched this part of the project for multiple years, I'm not sure I'll be the best person to review.

Okay, thanks. Hopefully @arsenm is better placed since they're using IPRA by default in AMDGPU

cme added a comment.Sep 8 2022, 7:25 AM

I haven't touched this part of the project for multiple years, I'm not sure I'll be the best person to review.

Or, would you be able to suggest anyone else that might be a suitable reviewer? Thanks.

arsenm added a comment.Sep 8 2022, 8:47 AM

For AMDGPU we special cased the RA handling in determineCalleeSaves

llvm/lib/CodeGen/TargetFrameLoweringImpl.cpp
130

It would be better to handle the list of special case registers rather than iterating through every CSR

arsenm requested changes to this revision.Dec 21 2022, 4:12 AM

Should at least avoid iterating every register for this

This revision now requires changes to proceed.Dec 21 2022, 4:12 AM