@@ -4159,7 +4159,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
4159
4159
// include as part of the module. All other jobs are expected to have exactly
4160
4160
// one input.
4161
4161
bool IsCuda = JA.isOffloading (Action::OFK_Cuda);
4162
+ bool IsCudaDevice = JA.isDeviceOffloading (Action::OFK_Cuda);
4162
4163
bool IsHIP = JA.isOffloading (Action::OFK_HIP);
4164
+ bool IsHIPDevice = JA.isDeviceOffloading (Action::OFK_HIP);
4163
4165
bool IsOpenMPDevice = JA.isDeviceOffloading (Action::OFK_OpenMP);
4164
4166
bool IsHeaderModulePrecompile = isa<HeaderModulePrecompileJobAction>(JA);
4165
4167
@@ -5003,8 +5005,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
5003
5005
// Prepare `-aux-target-cpu` and `-aux-target-feature` unless
5004
5006
// `--gpu-use-aux-triple-only` is specified.
5005
5007
if (!Args.getLastArg (options::OPT_gpu_use_aux_triple_only) &&
5006
- ((IsCuda && JA.isDeviceOffloading (Action::OFK_Cuda)) ||
5007
- (IsHIP && JA.isDeviceOffloading (Action::OFK_HIP)))) {
5008
+ (IsCudaDevice || IsHIPDevice)) {
5008
5009
const ArgList &HostArgs =
5009
5010
C.getArgsForToolChain (nullptr , StringRef (), Action::OFK_None);
5010
5011
std::string HostCPU =
@@ -5824,29 +5825,32 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
5824
5825
Args.MakeArgString (Twine (" -fcf-protection=" ) + A->getValue ()));
5825
5826
}
5826
5827
5827
- // Forward -f options with positive and negative forms; we translate
5828
- // these by hand.
5829
- if (Arg *A = getLastProfileSampleUseArg (Args)) {
5830
- auto *PGOArg = Args.getLastArg (
5831
- options::OPT_fprofile_generate, options::OPT_fprofile_generate_EQ,
5832
- options::OPT_fcs_profile_generate, options::OPT_fcs_profile_generate_EQ,
5833
- options::OPT_fprofile_use, options::OPT_fprofile_use_EQ);
5834
- if (PGOArg)
5835
- D.Diag (diag::err_drv_argument_not_allowed_with)
5836
- << " SampleUse with PGO options" ;
5828
+ // Forward -f options with positive and negative forms; we translate these by
5829
+ // hand. Do not propagate PGO options to the GPU-side compilations as the
5830
+ // profile info is for the host-side compilation only.
5831
+ if (!(IsCudaDevice || IsHIPDevice)) {
5832
+ if (Arg *A = getLastProfileSampleUseArg (Args)) {
5833
+ auto *PGOArg = Args.getLastArg (
5834
+ options::OPT_fprofile_generate, options::OPT_fprofile_generate_EQ,
5835
+ options::OPT_fcs_profile_generate,
5836
+ options::OPT_fcs_profile_generate_EQ, options::OPT_fprofile_use,
5837
+ options::OPT_fprofile_use_EQ);
5838
+ if (PGOArg)
5839
+ D.Diag (diag::err_drv_argument_not_allowed_with)
5840
+ << " SampleUse with PGO options" ;
5841
+
5842
+ StringRef fname = A->getValue ();
5843
+ if (!llvm::sys::fs::exists (fname))
5844
+ D.Diag (diag::err_drv_no_such_file) << fname;
5845
+ else
5846
+ A->render (Args, CmdArgs);
5847
+ }
5848
+ Args.AddLastArg (CmdArgs, options::OPT_fprofile_remapping_file_EQ);
5837
5849
5838
- StringRef fname = A->getValue ();
5839
- if (!llvm::sys::fs::exists (fname))
5840
- D.Diag (diag::err_drv_no_such_file) << fname;
5841
- else
5842
- A->render (Args, CmdArgs);
5850
+ if (Args.hasFlag (options::OPT_fpseudo_probe_for_profiling,
5851
+ options::OPT_fno_pseudo_probe_for_profiling, false ))
5852
+ CmdArgs.push_back (" -fpseudo-probe-for-profiling" );
5843
5853
}
5844
- Args.AddLastArg (CmdArgs, options::OPT_fprofile_remapping_file_EQ);
5845
-
5846
- if (Args.hasFlag (options::OPT_fpseudo_probe_for_profiling,
5847
- options::OPT_fno_pseudo_probe_for_profiling, false ))
5848
- CmdArgs.push_back (" -fpseudo-probe-for-profiling" );
5849
-
5850
5854
RenderBuiltinOptions (TC, RawTriple, Args, CmdArgs);
5851
5855
5852
5856
if (!Args.hasFlag (options::OPT_fassume_sane_operator_new,
0 commit comments