@@ -1008,6 +1008,35 @@ void SYCL::x86_64::BackendCompiler::ConstructJob(
1008
1008
C.addCommand (std::move (Cmd));
1009
1009
}
1010
1010
1011
+ // Unsupported options for device compilation
1012
+ // -fcf-protection, -fsanitize, -fprofile-generate, -fprofile-instr-generate
1013
+ // -ftest-coverage, -fcoverage-mapping, -fcreate-profile, -fprofile-arcs
1014
+ // -fcs-profile-generate -forder-file-instrumentation
1015
+ static std::vector<OptSpecifier> getUnsupportedOpts (void ) {
1016
+ std::vector<OptSpecifier> UnsupportedOpts = {
1017
+ options::OPT_fsanitize_EQ,
1018
+ options::OPT_fcf_protection_EQ,
1019
+ options::OPT_fprofile_generate,
1020
+ options::OPT_fprofile_generate_EQ,
1021
+ options::OPT_fno_profile_generate,
1022
+ options::OPT_ftest_coverage,
1023
+ options::OPT_fno_test_coverage,
1024
+ options::OPT_fcoverage_mapping,
1025
+ options::OPT_fno_coverage_mapping,
1026
+ options::OPT_fprofile_instr_generate,
1027
+ options::OPT_fprofile_instr_generate_EQ,
1028
+ options::OPT_fprofile_arcs,
1029
+ options::OPT_fno_profile_arcs,
1030
+ options::OPT_fno_profile_instr_generate,
1031
+ options::OPT_fcreate_profile,
1032
+ options::OPT_fprofile_instr_use,
1033
+ options::OPT_fprofile_instr_use_EQ,
1034
+ options::OPT_forder_file_instrumentation,
1035
+ options::OPT_fcs_profile_generate,
1036
+ options::OPT_fcs_profile_generate_EQ};
1037
+ return UnsupportedOpts;
1038
+ }
1039
+
1011
1040
SYCLToolChain::SYCLToolChain (const Driver &D, const llvm::Triple &Triple,
1012
1041
const ToolChain &HostTC, const ArgList &Args)
1013
1042
: ToolChain(D, Triple, Args), HostTC(HostTC),
@@ -1017,17 +1046,19 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
1017
1046
getProgramPaths ().push_back (getDriver ().Dir );
1018
1047
1019
1048
// Diagnose unsupported options only once.
1020
- // All sanitizer options are not currently supported, except AddressSanitizer
1021
- for (auto *A : Args.filtered (options::OPT_fsanitize_EQ,
1022
- options::OPT_fcf_protection_EQ)) {
1023
- if (A->getOption ().getID () == options::OPT_fsanitize_EQ &&
1024
- A->getValues ().size () == 1 ) {
1025
- std::string SanitizeVal = A->getValue ();
1026
- if (SanitizeVal == " address" )
1027
- continue ;
1049
+ for (OptSpecifier Opt : getUnsupportedOpts ()) {
1050
+ if (const Arg *A = Args.getLastArg (Opt)) {
1051
+ // All sanitizer options are not currently supported, except
1052
+ // AddressSanitizer
1053
+ if (A->getOption ().getID () == options::OPT_fsanitize_EQ &&
1054
+ A->getValues ().size () == 1 ) {
1055
+ std::string SanitizeVal = A->getValue ();
1056
+ if (SanitizeVal == " address" )
1057
+ continue ;
1058
+ }
1059
+ D.Diag (clang::diag::warn_drv_unsupported_option_for_target)
1060
+ << A->getAsString (Args) << getTriple ().str ();
1028
1061
}
1029
- D.getDiags ().Report (clang::diag::warn_drv_unsupported_option_for_target)
1030
- << A->getAsString (Args) << getTriple ().str ();
1031
1062
}
1032
1063
}
1033
1064
@@ -1053,27 +1084,27 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
1053
1084
for (Arg *A : Args) {
1054
1085
// Filter out any options we do not want to pass along to the device
1055
1086
// compilation.
1056
- auto Opt (A->getOption ().getID ());
1057
- switch (Opt) {
1058
- case options::OPT_fsanitize_EQ:
1059
- if (A->getValues ().size () == 1 ) {
1060
- std::string SanitizeVal = A->getValue ();
1061
- if (SanitizeVal == " address" ) {
1062
- if (IsNewDAL)
1063
- DAL->append (A);
1064
- continue ;
1087
+ auto Opt (A->getOption ());
1088
+ bool Unsupported = false ;
1089
+ for (OptSpecifier UnsupportedOpt : getUnsupportedOpts ()) {
1090
+ if (Opt.matches (UnsupportedOpt)) {
1091
+ if (A->getValues ().size () == 1 ) {
1092
+ std::string SanitizeVal = A->getValue ();
1093
+ if (SanitizeVal == " address" ) {
1094
+ if (IsNewDAL)
1095
+ DAL->append (A);
1096
+ continue ;
1097
+ }
1065
1098
}
1099
+ if (!IsNewDAL)
1100
+ DAL->eraseArg (Opt.getID ());
1101
+ Unsupported = true ;
1066
1102
}
1067
- [[fallthrough]];
1068
- case options::OPT_fcf_protection_EQ:
1069
- if (!IsNewDAL)
1070
- DAL->eraseArg (Opt);
1071
- break ;
1072
- default :
1073
- if (IsNewDAL)
1074
- DAL->append (A);
1075
- break ;
1076
1103
}
1104
+ if (Unsupported)
1105
+ continue ;
1106
+ if (IsNewDAL)
1107
+ DAL->append (A);
1077
1108
}
1078
1109
// Strip out -O0 for FPGA Hardware device compilation.
1079
1110
if (getDriver ().IsFPGAHWMode () &&
0 commit comments