aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorMichael Liao <michael.hliao@gmail.com>2020-02-03 15:35:18 -0500
committerMichael Liao <michael.hliao@gmail.com>2020-02-04 15:36:14 -0500
commitccac6b2bf877337a883c3763e41a529d8f9cc1ff (patch)
tree9c2be43f60c13185750047bda9eecd19d5c5e3bc /clang/lib/Frontend/CompilerInvocation.cpp
parentcfacf9ae20b8c97a428f118a2720bc109ba6a143 (diff)
downloadllvm-ccac6b2bf877337a883c3763e41a529d8f9cc1ff.zip
llvm-ccac6b2bf877337a883c3763e41a529d8f9cc1ff.tar.gz
llvm-ccac6b2bf877337a883c3763e41a529d8f9cc1ff.tar.bz2
[hip] Properly populate macros based on host processor.
Summary: - 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. - An internal option `--gpu-use-aux-triple-only` is added to fall back the original behavior to help diagnosing potential issues from the new behavior. Reviewers: tra, yaxunl Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73942
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 319f0d5..2fd66b6 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1931,6 +1931,10 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
Opts.OverrideRecordLayoutsFile =
std::string(Args.getLastArgValue(OPT_foverride_record_layout_EQ));
Opts.AuxTriple = std::string(Args.getLastArgValue(OPT_aux_triple));
+ if (Args.hasArg(OPT_aux_target_cpu))
+ Opts.AuxTargetCPU = std::string(Args.getLastArgValue(OPT_aux_target_cpu));
+ if (Args.hasArg(OPT_aux_target_feature))
+ Opts.AuxTargetFeatures = Args.getAllArgValues(OPT_aux_target_feature);
Opts.StatsFile = std::string(Args.getLastArgValue(OPT_stats_file));
if (const Arg *A = Args.getLastArg(OPT_arcmt_check,