@@ -576,6 +576,29 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
576576 }
577577 };
578578
579+ addLibraries (SYCLDeviceWrapperLibs);
580+ if (IsSpirvAOT)
581+ addLibraries (SYCLDeviceFallbackLibs);
582+
583+ bool NativeBfloatLibs;
584+ bool NeedBfloatLibs = selectBfloatLibs (TargetTriple, C, NativeBfloatLibs);
585+ if (NeedBfloatLibs) {
586+ // Add native or fallback bfloat16 library.
587+ if (NativeBfloatLibs)
588+ addLibraries (SYCLDeviceBfloat16NativeLib);
589+ else
590+ addLibraries (SYCLDeviceBfloat16FallbackLib);
591+ }
592+
593+ // Link in ITT annotations library unless fsycl-no-instrument-device-code
594+ // is specified. This ensures that we are ABI-compatible with the
595+ // instrumented device code, which was the default not so long ago.
596+ if (Args.hasFlag (options::OPT_fsycl_instrument_device_code,
597+ options::OPT_fno_sycl_instrument_device_code, true ))
598+ addLibraries (SYCLDeviceAnnotationLibs);
599+
600+ #if !defined(_WIN32)
601+
579602 auto addSingleLibrary = [&](const DeviceLibOptInfo &Lib) {
580603 if (!DeviceLibLinkInfo[Lib.DeviceLibOption ])
581604 return ;
@@ -636,28 +659,6 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
636659 return JIT;
637660 };
638661
639- addLibraries (SYCLDeviceWrapperLibs);
640- if (IsSpirvAOT)
641- addLibraries (SYCLDeviceFallbackLibs);
642-
643- bool NativeBfloatLibs;
644- bool NeedBfloatLibs = selectBfloatLibs (TargetTriple, C, NativeBfloatLibs);
645- if (NeedBfloatLibs) {
646- // Add native or fallback bfloat16 library.
647- if (NativeBfloatLibs)
648- addLibraries (SYCLDeviceBfloat16NativeLib);
649- else
650- addLibraries (SYCLDeviceBfloat16FallbackLib);
651- }
652-
653- // Link in ITT annotations library unless fsycl-no-instrument-device-code
654- // is specified. This ensures that we are ABI-compatible with the
655- // instrumented device code, which was the default not so long ago.
656- if (Args.hasFlag (options::OPT_fsycl_instrument_device_code,
657- options::OPT_fno_sycl_instrument_device_code, true ))
658- addLibraries (SYCLDeviceAnnotationLibs);
659-
660- #if !defined(_WIN32)
661662 std::string SanitizeVal;
662663 size_t sanitizer_lib_idx = getSingleBuildTarget ();
663664 if (Arg *A = Args.getLastArg (options::OPT_fsanitize_EQ,
@@ -1618,6 +1619,23 @@ static std::vector<OptSpecifier> getUnsupportedOpts(void) {
16181619 return UnsupportedOpts;
16191620}
16201621
1622+ // Currently supported options by SYCL NativeCPU device compilation
1623+ static inline bool SupportedByNativeCPU (const SYCLToolChain &TC,
1624+ const OptSpecifier &Opt) {
1625+ if (!TC.IsSYCLNativeCPU )
1626+ return false ;
1627+
1628+ switch (Opt.getID ()) {
1629+ case options::OPT_fcoverage_mapping:
1630+ case options::OPT_fno_coverage_mapping:
1631+ case options::OPT_fprofile_instr_generate:
1632+ case options::OPT_fprofile_instr_generate_EQ:
1633+ case options::OPT_fno_profile_instr_generate:
1634+ return true ;
1635+ }
1636+ return false ;
1637+ }
1638+
16211639SYCLToolChain::SYCLToolChain (const Driver &D, const llvm::Triple &Triple,
16221640 const ToolChain &HostTC, const ArgList &Args)
16231641 : ToolChain(D, Triple, Args), HostTC(HostTC),
@@ -1629,6 +1647,9 @@ SYCLToolChain::SYCLToolChain(const Driver &D, const llvm::Triple &Triple,
16291647 // Diagnose unsupported options only once.
16301648 for (OptSpecifier Opt : getUnsupportedOpts ()) {
16311649 if (const Arg *A = Args.getLastArg (Opt)) {
1650+ // Native CPU can support options unsupported by other targets.
1651+ if (SupportedByNativeCPU (*this , Opt))
1652+ continue ;
16321653 // All sanitizer options are not currently supported, except
16331654 // AddressSanitizer
16341655 if (A->getOption ().getID () == options::OPT_fsanitize_EQ &&
@@ -1669,6 +1690,9 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
16691690 bool Unsupported = false ;
16701691 for (OptSpecifier UnsupportedOpt : getUnsupportedOpts ()) {
16711692 if (Opt.matches (UnsupportedOpt)) {
1693+ // NativeCPU should allow most normal cpu options.
1694+ if (SupportedByNativeCPU (*this , Opt.getID ()))
1695+ continue ;
16721696 if (Opt.getID () == options::OPT_fsanitize_EQ &&
16731697 A->getValues ().size () == 1 ) {
16741698 std::string SanitizeVal = A->getValue ();
0 commit comments