This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SME] Implement ABI for calls from streaming-compatible functions.
ClosedPublic

Authored by sdesmalen on Aug 10 2022, 8:39 AM.

Details

Summary

When a function is streaming-compatible and calls a function with a normal or streaming
interface, it may need to enable/disable stremaing mode before the call, and
needs to restore PSTATE.SM after the call.

This patch implements this with a Pseudo node that gets expanded to a
conditional branch and smstart/smstop node.

More details about the SME attributes and design can be found
in D131562.

Diff Detail

Event Timeline

sdesmalen created this revision.Aug 10 2022, 8:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 8:39 AM
sdesmalen requested review of this revision.Aug 10 2022, 8:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 8:39 AM
shruthiashwath added inline comments.Aug 18 2022, 6:54 PM
llvm/test/CodeGen/AArch64/sme-streaming-compatible-interface.ll
256

For the function 'normal_callee_scalable_vec_arg', the declaration and the call both have different types.

aemerson added inline comments.
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
2360–2367

Not a big deal, but this seems like an odd optimization to do. One would think that this would be infrequent enough that we wouldn't need to add special handling for it, and if it's not infrequent, why?

sdesmalen updated this revision to Diff 459068.Sep 9 2022, 8:07 AM
sdesmalen marked an inline comment as done.

Fixed type of '@normal_callee_scalable_vec_arg' in test.

Moved expansion of pseudo node to the AArch64ExpandPseudoInsts pass. By having
it as a pseudo after SelectionDAG, we have the possibility to optimise
back-to-back smstart/smstop nodes. When control is introduced, this is much
harder.

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
2360–2367

The code later expects that the block can be split at MI and that the block has successors. It will fail if we don't bail out early.

We encountered this case around exception handling code generated by Clang.

llvm/test/CodeGen/AArch64/sme-streaming-compatible-interface.ll
256

Good catch!

LGTM with comment.

llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
859

Maybe mention here under what circumstances this might be common.

aemerson accepted this revision.Sep 14 2022, 2:11 PM
This revision is now accepted and ready to land.Sep 14 2022, 2:11 PM
This revision was landed with ongoing or failed builds.Sep 16 2022, 7:49 AM
This revision was automatically updated to reflect the committed changes.
sdesmalen marked an inline comment as done.