This is an archive of the discontinued LLVM Phabricator instance.

[X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.
ClosedPublic

Authored by vsapsai on May 6 2019, 4:15 PM.

Details

Summary

Currently immintrin.h includes pconfigintrin.h and sgxintrin.h
which contain inline assembly. It causes failures when building with the
flag -fno-gnu-inline-asm.

Fix by excluding functions with inline assembly when this extension is
disabled. So far there was no need to support _pconfig_u32,
_enclu_u32, _encls_u32, _enclv_u32 on platforms that require
-fno-gnu-inline-asm. But if developers start using these functions,
they'll have compile-time undeclared identifier errors which is
preferrable to runtime errors.

rdar://problem/49540880

Diff Detail

Repository
rL LLVM

Event Timeline

vsapsai created this revision.May 6 2019, 4:15 PM
rnk added a comment.May 7 2019, 4:18 PM

I see one more instance of unprotected asm usage, but it's under #ifdef _MSC_VER, it's the HLE extensions. Can you protect that, and then add another RUN line with a windows triple and -fms-extensions to test it?

vsapsai updated this revision to Diff 198875.May 9 2019, 11:05 AM
  • Improve -fno-gnu-inline-asm support for MS-compatibility too.

Didn't use -fms-compatibility in the test and it seems to be working fine.
Don't know if it is accidental and if I should add the flag.

rnk accepted this revision.May 9 2019, 11:53 AM

lgtm, thanks!

Didn't use -fms-compatibility in the test and it seems to be working fine.
Don't know if it is accidental and if I should add the flag.

-fms-extensions is probably all you need. That's the one that defines _MSC_VER.

This revision is now accepted and ready to land.May 9 2019, 11:53 AM
In D61621#1497027, @rnk wrote:

lgtm, thanks!

Didn't use -fms-compatibility in the test and it seems to be working fine.
Don't know if it is accidental and if I should add the flag.

-fms-extensions is probably all you need. That's the one that defines _MSC_VER.

Thanks for extra information and for the review. In my testing it was -fms-compatibility-version that defines _MSC_VER on macOS. I haven't tested extensively but looks like for the driver -fms-extensions should be enough but for -cc1 you need -fms-compatibility-version.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 13 2019, 3:38 PM