This is a patch for PR34167.
On HF targets functions like __{eq,lt,le,ge,gt}df2 and __{eq,lt,le,ge,gt}sf2 expect their arguments to be passed in d/s registers, while some of the AEABI builtins pass them in r registers.
Differential D36675
[ARM][Compiler-rt] Fix AEABI builtins to correctly pass arguments to non-AEABI functions on HF targets iid_iunknown on Aug 14 2017, 6:24 AM. Authored by
Details
This is a patch for PR34167. On HF targets functions like __{eq,lt,le,ge,gt}df2 and __{eq,lt,le,ge,gt}sf2 expect their arguments to be passed in d/s registers, while some of the AEABI builtins pass them in r registers.
Diff Detail
Event TimelineComment Actions The code changes look fine to me. I haven't managed to find an existing test case that explicitly calls aeabi_fcmp and aeabi_dcmp for a hard float target. Would it be possible to add one so that we can make sure that we catch any future problems?
Comment Actions Um, when LLVM makes the invocation, it will assume that s0/s1 are not clobbered, even though it is a function call. Shouldn't we be explicitly saving and restoring s0/s1 in the ARM HF cases? Comment Actions By my reading of the AAPCS http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf (5.1.2.1 VFP register usage conventions (VFP v2, v3 and the Advanced SIMD Extension) I can try and double check this tomorrow. Comment Actions Not quite. Here is the full list of callee-saved registers: def CSR_AAPCS : CalleeSavedRegs<(add LR, R11, R10, R9, R8, R7, R6, R5, R4, (sequence "D%u", 15, 8))>; Everything else is callee clobbered and therefore should be saved by a caller. Comment Actions Thanks for the feedback, Peter!
Good point. I will update the patch.
This problem was caught using the standard compiler-rt test suite :) The tests are test/builtins/Unit/arm/aeabi_cfcmpeq_test.c and test/builtins/Unit/arm/aeabi_cdcmpeq_test.c. test -> __aeabi_cfcmpeq -> __aeabi_cfcmple -> __aeabi_fcmpeq -> __eqsf2 However, I can't find an LLVM buildbot that builds and runs the compiler-rt tests for ARM. Comment Actions Thanks for making the changes. If this is covered by an existing test case I'm happy.
Interesting; I've used a cross-compilation of compiler-rt for ARM using qemu-arm to run the tests, sadly when I look at the logs in more detail I get UNSUPPORTED: Builtins-armhf-linux :: arm/aeabi_cdcmple_test.c (3 of 194) Test requires the following unavailable features: arm-target-arch || armv6m-target-arch I'll need to work out why my target (default armv7--linux-gnueabihf) got rejected. As an aside it would be interesting to know what target you used? Ideally it would be great to get compiler-rt able to build and run its tests for all the ARM architectures running via QEMU as a buildbot that could build all the supported platforms would be much faster than a native build-bot, and may be the only way for the M class builds. Comment Actions
Yes, I had to manually add arm-target-arch to available features to enable these tests. if target_arch in ['x86_64', 'i386', 'i686']: config.available_features.add('x86-target-arch') For ARM we now have only config.available_features.add(target_arch + '-target-arch') so the armv7--linux-gnueabihf triple gives us armv7-target-arch that does not match the test's requirements. Comment Actions Thank you very much for the tip. Yes that approach looks like it would be worthwhile checking out. Comment Actions Hi Peter, Would you mind if I commit this patch? Comment Actions I'm ok with this, I've set the status to approved, although it will be worth waiting a day or so to see if compnerd has any objections. Comment Actions Given that this is regression from 3.9 and it's release-critical, I'd would suggest to commit it now. After all, the patch was in review for more than a week. Comment Actions Peter, Anton, I am going to commit the patch shortly. |
Is it worth making the macro name less generic as it only applies to this specific case, and could clash with a future definition at a higher level scope?