[PATCH] D50845: [CUDA/OpenMP] Define only some host macros during device compilation

Jonas Hahnfeld via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 16 07:56:20 PDT 2018


Hahnfeld created this revision.
Hahnfeld added reviewers: tra, gtbercea, hfinkel.
Herald added subscribers: cfe-commits, guansong.

When compiling CUDA or OpenMP device code Clang parses header files
that expect certain predefined macros from the host architecture. To
make this work the compiler passes the host triple via the -aux-triple
argument and (until now) pulls in all macros for that "auxiliary triple"
unconditionally.

However this results in defines like __SSE_MATH__ that will trigger
inline assembly making use of the "advertised" target features. See
the discussion of https://reviews.llvm.org/D47849 and PR38464 for a detailed explanation of
the encountered problems.

Instead of blacklisting "known bad" examples this patch starts adding
defines that are needed for certain headers like bits/wordsize.h and
bits/mathinline.h.
The disadvantage of this approach is that it decouples the definitions
from their target toolchain. However in my opinion it's more important
to keep definitions for one header close together. For one this will
include a clear documentation why these particular defines are needed.
Furthermore it simplifies maintenance because adding defines for a new
header or support for a new aux-triple only needs to touch one piece
of code.


Repository:
  rC Clang

https://reviews.llvm.org/D50845

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/aux-triple.c
  test/SemaCUDA/builtins.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50845.161032.patch
Type: text/x-patch
Size: 4799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180816/e9e5d364/attachment.bin>


More information about the cfe-commits mailing list