This is an archive of the discontinued LLVM Phabricator instance.

[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

Is there a reason this never landed?

Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2023, 12:10 PM
asl added a comment.Jul 21 2023, 12:44 PM

Is there a reason this never landed?

Good question. @atrosinenko ?

Sorry for a hung patch. After getting the approval I had doubts that I interpret the corner cases of LLVM IR correctly. Thus, I postponed the patch these days to not subtly break the stable targets while fixing one issue on MSP430.

I can re-evaluate this patch if it is still relevant.