This is an archive of the discontinued LLVM Phabricator instance.

[X86] Correct the value of MaxAtomicInlineWidth for pre-586 cpus
ClosedPublic

Authored by craig.topper on Mar 19 2019, 2:53 PM.

Details

Summary

MaxAtomicInlineWidth should be 32 bits on CPUs prior to 586 when CMPXCHG8B was added.

The test changes just add -target-cpu pentium4 as a post-586 chip to keep the content working. I believe pentium4 is the default CPU we use in the driver for at least 32-bit linux.

What's the minimum test needed to ensure that 386/486 CPUs get the right value?

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Mar 19 2019, 2:53 PM
craig.topper added a subscriber: erichkeane.

Technically, I guess the default for MaxAtomicInlineWidth should be zero, since 386 doesn't have cmpxchg... but I don't think anyone cares, so we'll pretend 486 is the oldest possible x86 processor. Probably enough to just have a test to check that the defines are set properly for an 486 target.

We should probably also fix the LLVM backend to add a cmpxchg8 feature bit.

Rewrite to use a "cx8" feature flag that is set for all i586 and greater CPUs as well as generic. This assumes generic is never passed in a run of clang through the driver. And anyone using -cc1 directly is unlikely to be using an i486.

I've updated the init.c test to use i486 for the NETBSD test since I think that's what the driver defaults to. This is used as the test for i486. I've added command lines with -malign-double set which should force 64-bit types to have 64 bit alignment instead of the default 32 bit alignment. This is needed to get the LLONG_LOCK_FREE macro to be 2 on i586 and greater.

Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2019, 12:22 AM
efriedma accepted this revision.Mar 21 2019, 12:24 PM

LGTM

This is needed to get the LLONG_LOCK_FREE macro to be 2 on i586 and greater.

Not sure these tests are really valuable, given we plan to change that immediately after this is merged, but fine, I guess.

This revision is now accepted and ready to land.Mar 21 2019, 12:24 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 21 2019, 1:35 PM