This is an archive of the discontinued LLVM Phabricator instance.

Fix ARM AAPCS regression caused by r211898
ClosedPublic

Authored by olista01 on Jul 16 2014, 9:36 AM.

Details

Summary

r211898 introduced a regression where a large struct, which would normally be passed ByVal, was causing padding to be inserted to prevent the backend from using some GPRs, in order to follow the AAPCS. However, the type of the argument was not being set correctly, so the backend cannot align 8-byte aligned struct types on the stack.

The fix is to not insert the padding arguments when the argument is being passed ByVal.

Diff Detail

Event Timeline

olista01 updated this revision to Diff 11517.Jul 16 2014, 9:36 AM
olista01 retitled this revision from to Fix ARM AAPCS regression caused by r211898.
olista01 updated this object.
olista01 edited the test plan for this revision. (Show Details)
olista01 added reviewers: t.p.northover, rengolin.
olista01 added a subscriber: Unknown Object (MLST).
olista01 updated this object.Jul 16 2014, 9:36 AM
rengolin edited edge metadata.Jul 16 2014, 1:35 PM

I don't think there are enough changes here to warrant a bigger refactoring, but this mechanism has proven to be fragile, given the number of "this commit broke byval" post-commits.

I'm not against this particular patch, but I'd like to see a bit more work on making the code robust, not just adding special cases...

cheers,
--renato

lib/CodeGen/TargetInfo.cpp
4004

This is getting slightly out of hand...

test/CodeGen/arm-aapcs-vfp.c
150

and this relationship between the front-end and the back-end is getting thinner...

We could simply disable the use of byval for ARM, as it is not required for ABI correctness. Two of my 5 most recent ABI-related commits have been directly related to byval arguments. Do you know what the purpose of byval is, and if there would be any downside to not using it? Does it allow for some optimisation at the IR level? Even if it does, it is probably not a very significant gain as it is only used for very large types passed by value, and the implementation in the ARM backend generates unnecessary stores to the stack in a lot of cases.

rengolin accepted this revision.Jul 17 2014, 12:35 PM
rengolin edited edge metadata.

Hi Oliver,

ByVal is normally a big deal for performance when structures are passed as arguments, and I don't think we should disable it like that. I don't have benchmark numbers to tell if it really is worth keep it, maybe you can disable it and run some benchmarks.

All in all, this commit looks ok and if no one is against it, feel free to commit. We can leave the ByVal discussion for later.

cheers,
--renato

This revision is now accepted and ready to land.Jul 17 2014, 12:35 PM
olista01 closed this revision.Jul 18 2014, 2:19 AM

Committed revision 213359.

I'll have a look and see if we have any benchmarks that this might affect, but I have a feeling that passing 64 byte+ structs by value is not a common thing to do, especially in performance-sensitive code.