[PATCH] D73942: [hip] Properly populate macros based on host processor.

Michael Liao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 3 20:22:29 PST 2020


hliao created this revision.
hliao added reviewers: tra, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- The device compilation needs to have a consistent source code compared to the corresponding host compilation. If macros based on the host-specific target processor is not properly populated, the device compilation may fail due to the inconsistent source after the preprocessor. So far, only the host triple is used to build the macros. If a detailed host CPU target or certain features are specified, macros derived from them won't be populated properly, e.g. `__SSE3__` won't be added unless `+sse3` feature is present. On Windows compilation compatible with MSVC, that missing macros result in that intrinsics are not included and cause device compilation failure on the host-side source.

- This patch addresses this issue by introducing two `cc1` options, i.e., `-aux-target-cpu` and `-aux-target-feature`. If a specific host CPU target or certain features are specified, the compiler driver will append them during the construction of the offline compilation actions. Then, the toolchain in `cc1` phase will populate macros accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73942

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Preprocessor/hip-host-cpu-macros.cu

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73942.242249.patch
Type: text/x-patch
Size: 6123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200204/696e2d69/attachment.bin>


More information about the cfe-commits mailing list