This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Add AArch64 to CMake configuration and several missing builtins
ClosedPublic

Authored by sdmitrouk on Jul 31 2015, 7:34 AM.

Details

Summary

Currently CMake doesn't build builtins for AArch64 and if one does this anyway
it's likely that at least __multc3, __floatditf and __floatunditf will be
missing. There is actually more builtins to add, but these come from
different libc implementations, thus providing them makes compiler-rt for
AArch64 good enough at least for basic usage.

Builtins implementation were originally taken from FreeBSD project:

Until they have been tested to find mistakes in __float* functions.
__floatditf was based on __floatsitf, which had the same mistakes
(fixed it in r243746).

Version of the builtins in this patch are fixed and complemented with basic
tests. Additionally they were tested via GCC's torture (this is what revealed
these issues).

P.S. Ed (author of FreeBSD patches) asked for feedback on the list some time ago (here here)
and got no response, but it seems to be worth adding these builtins as is and
extracting common part later.

Diff Detail

Repository
rL LLVM

Event Timeline

sdmitrouk updated this revision to Diff 31119.Jul 31 2015, 7:34 AM
sdmitrouk retitled this revision from to [compiler-rt] Add AArch64 to CMake configuration and several missing builtins.
sdmitrouk updated this object.
sdmitrouk added reviewers: howard.hinnant, rengolin.
sdmitrouk set the repository for this revision to rL LLVM.
sdmitrouk added subscribers: llvm-commits, samsonov, emaste.

I have to say I didn't delve into the IEEE-ness of the algorithms, but I welcome some builtins in AArch64.

I'm adding some AArch64 folks to have a look at the code, but generally if Ed is happy, I'm happy. :)

Where have you tested this? Does "make check-all" pass when compiling RT with Clang? That's what the buildbot will do, so it needs to be green.

cheers,
--renato

Renato,

Where have you tested this?

On Qemu, don't have usable AArch64 board.

Does "make check-all" pass when compiling RT with Clang? That's what the buildbot will do, so it needs to be green.

I should get used to look up build instructions in www/, ran tests in a weird way. There are seven failures of existing builtins (by the way, these and one more of tests don't even compile out of the box due to missing include, which is obviously easy to fix):

compiler-rt :: builtins :: Unit/divxc3_test.c
compiler-rt :: builtins :: Unit/fixtfsi_test.c
compiler-rt :: builtins :: Unit/fixunsxfti_test.c
compiler-rt :: builtins :: Unit/fixxfti_test.c
compiler-rt :: builtins :: Unit/floattixf_test.c
compiler-rt :: builtins :: Unit/floatuntixf_test.c
compiler-rt :: builtins :: Unit/multf3_test.c

So looks like adding AArch64 target is too early. Does it still makes sense to add missing builtins without updating configuration? It's not that easy to fix broken functions of this kind and I can't promise to do it soon, I wonder if these are actually used by someone at the moment.

Thanks,
Sergey

Hi Sergey,

I'd rather leave the first implementation to someone that can test on real hardware and turn the architecture on, even if that means XFAILing a few tests. But QEMU is not enough, and without a proper build, it's hard to put something in, even if it "looks ok".

cheers,
--renato

asl added a subscriber: asl.Jul 31 2015, 2:13 PM

So, this is not an endorsement, nor a certificate of achievement, but I just built Compiler-RT on an XGene, building the sanitizers, builtins, profiles, etc. and the build finishes and all tests pass.

However, this is not the same architecture we have for the buildbots (which is a Juno), nor it's a vanilla ARM core, so we can't assume it's kosher.

I'm adding Gabor (the Juno bot owner) to see if he can run some tests on that machine, and if that pass, we can go forward with the patch.

cheers,
--renato

Adding Adhemerval to have a look.

Now that we have ASAN on and the bots are green, it's a good time to add this one before the more controversial TSAN changes.

lib/builtins/multc3.c
21 ↗(On Diff #31119)

nitpick: is it necessary to have __ac and others, since they're all local context?

zatrazz edited edge metadata.Aug 12 2015, 12:50 PM

LGTM with the tests comment. I also have tested it with some random inputs (2^26) to check against GCC implementation and everything seems ok.

test/builtins/Unit/floatunditf_test.c
25 ↗(On Diff #31119)

This should be 'unsigned long long a'.

27 ↗(On Diff #31119)

Same as before.

45 ↗(On Diff #31119)

I think it is better to explicit use ULL constants for this all these tests.

rengolin accepted this revision.Aug 13 2015, 3:43 AM
rengolin edited edge metadata.

LGTM too. Thanks for the review.

This revision is now accepted and ready to land.Aug 13 2015, 3:43 AM
sdmitrouk marked 4 inline comments as done.Aug 17 2015, 9:40 AM

@zatrazz, thanks for the review and tests.

@rengolin, thank you for checks, review and finding reviewers!

Regards,
Sergey

lib/builtins/multc3.c
21 ↗(On Diff #31119)

I was wondering the same and checked other files, some of which contain __ prefixes, so I decided to leave as is unless it will bother anyone. I'll remove __.

rengolin added inline comments.Aug 17 2015, 9:44 AM
lib/builtins/multc3.c
21 ↗(On Diff #31119)

No worries, if that's the style.

sdmitrouk updated this revision to Diff 32318.Aug 17 2015, 9:49 AM
sdmitrouk edited edge metadata.
sdmitrouk marked an inline comment as done.

Address review comments.

This revision was automatically updated to reflect the committed changes.