Page MenuHomePhabricator

[MSP430] Fix passing C structs and unions as function arguments
AcceptedPublic

Authored by atrosinenko on Aug 13 2020, 11:12 AM.

Details

Summary

Pass structures, classes and unions by reference on MSP430, according to Section 3.5 of MSP430 EABI. The callee is responsible for leaving the underlying data intact.

Diff Detail

Event Timeline

atrosinenko created this revision.Aug 13 2020, 11:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2020, 11:12 AM
atrosinenko requested review of this revision.Aug 13 2020, 11:13 AM

Restore test formatting.

Harbormaster completed remote builds in B68299: Diff 285436.

Update with implicit pointers being passed through.

rjmccall accepted this revision.Aug 17 2020, 1:36 PM

LGTM

clang/lib/CodeGen/TargetInfo.cpp
7523

Oh wow, the ABI really is indirect aliased:

To pass a structure or union by reference, the caller places its address
in the appropriate location: either in a register or on the stack, according
to its position in the argument list. To preserve pass-by-value semantics
(required for C and C++), the callee may need to make its own copy of the
pointed-to object. In some cases, the callee need not make a copy, such
as if the callee is a leaf and it does not modify the pointed-to object.

I didn't realize any actual ABIs did this.

This revision is now accepted and ready to land.Aug 17 2020, 1:36 PM