From 6047e1494f1b7be182045ac5f2bc4ba239e451ea Mon Sep 17 00:00:00 2001 From: Michael D Toguchi Date: Fri, 1 Nov 2024 16:54:29 -0700 Subject: [PATCH] [Driver][SYCL][NFC] Updates to sync up with upstream To better match up with what is occurring in the upstream, sync up the changes in the driver. This sync-up should make it easier to push future changes upstream and reduce confusion as items are pulled down. Changes include updates to function names, comment updates and some restructuring of how options are passed to the clang -cc1 step. --- clang/include/clang/Driver/Driver.h | 4 +- clang/include/clang/Driver/ToolChain.h | 2 +- clang/lib/Driver/Compilation.cpp | 2 +- clang/lib/Driver/Driver.cpp | 84 ++-- clang/lib/Driver/ToolChain.cpp | 2 +- clang/lib/Driver/ToolChains/Clang.cpp | 399 +++++++++--------- clang/lib/Driver/ToolChains/SYCL.cpp | 8 +- .../test/Driver/sycl-int-footer-old-model.cpp | 12 +- clang/test/Driver/sycl-int-header-footer.cpp | 12 +- clang/test/Driver/sycl-offload-aot.cpp | 2 +- clang/test/Driver/sycl-offload-intelfpga.cpp | 6 +- clang/test/Driver/sycl-offload-new-driver.c | 2 +- .../sycl-offload-save-temps-old-model.cpp | 2 +- clang/test/Driver/sycl-offload-save-temps.cpp | 2 +- .../test/Driver/sycl-preprocess-old-model.cpp | 2 +- clang/test/Driver/sycl-preprocess.cpp | 2 +- .../Driver/sycl-unique-prefix-old-model.cpp | 6 +- clang/test/Driver/sycl-unique-prefix.cpp | 6 +- 18 files changed, 280 insertions(+), 275 deletions(-) diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 9f423d5f92626..47d2f9b11bc0e 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -586,9 +586,9 @@ class Driver { /// @name Helper Methods /// @{ - /// MakeSYCLDeviceTriple - Returns the SYCL device triple for the + /// getSYCLDeviceTriple - Returns the SYCL device triple for the /// specified subarch - llvm::Triple MakeSYCLDeviceTriple(StringRef TargetArch = "spir64") const; + llvm::Triple getSYCLDeviceTriple(StringRef TargetArch = "spir64") const; /// PrintActions - Print the list of actions. void PrintActions(const Compilation &C) const; diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 5954f2c29676e..16c33b77c0f31 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -781,7 +781,7 @@ class ToolChain { virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const; - /// Add arguments to use SYCL specific includes. + /// Add arguments to use system-specific SYCL includes. virtual void AddSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const; diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index 2e85f85fbc1c1..3978e696932e6 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/lib/Driver/Compilation.cpp @@ -344,7 +344,7 @@ static bool ActionFailed(const Action *A, // CUDA/HIP/SYCL can have the same input source code compiled multiple times // so do not compile again if there are already failures. It is OK to abort - // the CUDA pipeline on errors. + // the CUDA/HIP/SYCL pipeline on errors. if (A->isOffloading(Action::OFK_Cuda) || A->isOffloading(Action::OFK_HIP) || A->isOffloading(Action::OFK_SYCL)) return true; diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index b0f74466e715e..71068f40d1337 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -834,6 +834,7 @@ static bool isValidSYCLTriple(llvm::Triple T) { } static const char *getDefaultSYCLArch(Compilation &C) { + // If -fsycl is supplied we will assume SPIR-V if (C.getDefaultToolChain().getTriple().getArch() == llvm::Triple::x86) return "spir"; return "spir64"; @@ -847,7 +848,7 @@ static bool addSYCLDefaultTriple(Compilation &C, if (C.getInputArgs().hasArg(options::OPT_fsycl_force_target_EQ)) return false; llvm::Triple DefaultTriple = - C.getDriver().MakeSYCLDeviceTriple(getDefaultSYCLArch(C)); + C.getDriver().getSYCLDeviceTriple(getDefaultSYCLArch(C)); for (const auto &SYCLTriple : SYCLTriples) { if (SYCLTriple == DefaultTriple) return false; @@ -1079,22 +1080,21 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // We need to generate a SYCL toolchain if the user specified -fsycl. // If -fsycl is supplied without any of these we will assume SPIR-V. // Use of -fsycl-device-only overrides -fsycl. - bool HasValidSYCLRuntime = - C.getInputArgs().hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, - false) || - C.getInputArgs().hasArg(options::OPT_fsycl_device_only); + bool IsSYCL = C.getInputArgs().hasFlag(options::OPT_fsycl, + options::OPT_fno_sycl, false) || + C.getInputArgs().hasArg(options::OPT_fsycl_device_only); Arg *SYCLfpga = C.getInputArgs().getLastArg(options::OPT_fintelfpga); // Make -fintelfpga flag imply -fsycl. - if (SYCLfpga && !HasValidSYCLRuntime) - HasValidSYCLRuntime = true; + if (SYCLfpga && !IsSYCL) + IsSYCL = true; // A mechanism for retrieving SYCL-specific options, erroring out // if SYCL offloading wasn't enabled prior to that auto getArgRequiringSYCLRuntime = [&](OptSpecifier OptId) -> Arg * { Arg *SYCLArg = C.getInputArgs().getLastArg(OptId); - if (SYCLArg && !HasValidSYCLRuntime) { + if (SYCLArg && !IsSYCL) { Diag(clang::diag::err_drv_expecting_fsycl_with_sycl_opt) // Dropping the '=' symbol, which would otherwise pollute // the diagnostics for the most of options @@ -1123,7 +1123,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, << "-fsycl-host-compiler"; auto argSYCLIncompatible = [&](OptSpecifier OptId) { - if (!HasValidSYCLRuntime) + if (!IsSYCL) return; if (Arg *IncompatArg = C.getInputArgs().getLastArg(OptId)) Diag(clang::diag::err_drv_argument_not_allowed_with) @@ -1182,7 +1182,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, getArgRequiringSYCLRuntime(options::OPT_fsycl_force_target_EQ); if (SYCLForceTarget) { StringRef Val(SYCLForceTarget->getValue()); - llvm::Triple TT(MakeSYCLDeviceTriple(Val)); + llvm::Triple TT(getSYCLDeviceTriple(Val)); if (!isValidSYCLTriple(TT)) Diag(clang::diag::err_drv_invalid_sycl_target) << Val; } @@ -1240,7 +1240,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, continue; } - llvm::Triple DeviceTriple(MakeSYCLDeviceTriple(UserTargetName)); + llvm::Triple DeviceTriple(getSYCLDeviceTriple(UserTargetName)); if (!isValidSYCLTriple(DeviceTriple)) { Diag(clang::diag::err_drv_invalid_sycl_target) << Val; continue; @@ -1271,7 +1271,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, } // Make sure we don't have a duplicate triple. - std::string NormalizedName = MakeSYCLDeviceTriple(Val).normalize(); + std::string NormalizedName = getSYCLDeviceTriple(Val).normalize(); auto Duplicate = FoundNormalizedTriples.find(NormalizedName); if (Duplicate != FoundNormalizedTriples.end()) { Diag(clang::diag::warn_drv_sycl_offload_target_duplicate) @@ -1303,9 +1303,8 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // Create a toolchain for each valid triple. // We do not support SYCL offloading if any of the inputs is a // .cu (for CUDA type) or .hip (for HIP type) file. - else if (HasValidSYCLRuntime && - C.getInputArgs().hasArg(options::OPT_offload_arch_EQ) && !IsHIP && - !IsCuda) { + else if (IsSYCL && C.getInputArgs().hasArg(options::OPT_offload_arch_EQ) && + !IsHIP && !IsCuda) { // SYCL offloading to AOT Targets with '--offload-arch' // is currently enabled only with '--offload-new-driver' option. // Emit a diagnostic if '--offload-arch' is invoked without @@ -1352,7 +1351,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, getProcessorFromTargetID(*AMDTriple, Arch)))) { DerivedArchs[AMDTriple->getTriple()].insert(Arch); } else if (IsSYCLSupportedIntelCPUArch(StringToOffloadArchSYCL(Arch))) { - DerivedArchs[MakeSYCLDeviceTriple("spir64_x86_64").getTriple()].insert( + DerivedArchs[getSYCLDeviceTriple("spir64_x86_64").getTriple()].insert( Arch); } else if (IsSYCLSupportedIntelGPUArch(StringToOffloadArchSYCL(Arch))) { StringRef IntelGPUArch; @@ -1363,7 +1362,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // offloading to Intel GPUs and the corresponding '-device' value passed // to OCLOC. IntelGPUArch = mapIntelGPUArchName(Arch).data(); - DerivedArchs[MakeSYCLDeviceTriple("spir64_gen").getTriple()].insert( + DerivedArchs[getSYCLDeviceTriple("spir64_gen").getTriple()].insert( IntelGPUArch); } else { Diag(clang::diag::err_drv_invalid_sycl_target) << Arch; @@ -1381,7 +1380,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, SYCLTriples.insert(TripleAndArchs.first()); for (const auto &Val : SYCLTriples) { - llvm::Triple SYCLTargetTriple(MakeSYCLDeviceTriple(Val.getKey())); + llvm::Triple SYCLTargetTriple(getSYCLDeviceTriple(Val.getKey())); std::string NormalizedName = SYCLTargetTriple.normalize(); // Make sure we don't have a duplicate triple. @@ -1403,12 +1402,12 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, } else { // If -fsycl is supplied without -fsycl-targets we will assume SPIR-V. // For -fsycl-device-only, we also setup the implied triple as needed. - if (HasValidSYCLRuntime) { + if (IsSYCL) { StringRef SYCLTargetArch = getDefaultSYCLArch(C); if (SYCLfpga) // Triple for -fintelfpga is spir64_fpga. SYCLTargetArch = "spir64_fpga"; - UniqueSYCLTriplesVec.push_back(MakeSYCLDeviceTriple(SYCLTargetArch)); + UniqueSYCLTriplesVec.push_back(getSYCLDeviceTriple(SYCLTargetArch)); addSYCLDefaultTriple(C, UniqueSYCLTriplesVec); } } @@ -2529,7 +2528,7 @@ void Driver::PrintHelp(bool ShowHidden) const { VisibilityMask); } -llvm::Triple Driver::MakeSYCLDeviceTriple(StringRef TargetArch) const { +llvm::Triple Driver::getSYCLDeviceTriple(StringRef TargetArch) const { SmallVector SYCLAlias = { "spir", "spir64", "spir64_fpga", "spir64_x86_64", "spir64_gen", "spirv32", "spirv64", "nvptx64"}; @@ -2557,13 +2556,13 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const { StringRef AV(A->getValue()); llvm::Triple T; if (AV == "gen" || AV == "all") - HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_gen"), + HelpArgs.push_back(std::make_tuple(getSYCLDeviceTriple("spir64_gen"), "ocloc", "--help", "")); if (AV == "fpga" || AV == "all") - HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_fpga"), + HelpArgs.push_back(std::make_tuple(getSYCLDeviceTriple("spir64_fpga"), "aoc", "-help", "-sycl")); if (AV == "x86_64" || AV == "all") - HelpArgs.push_back(std::make_tuple(MakeSYCLDeviceTriple("spir64_x86_64"), + HelpArgs.push_back(std::make_tuple(getSYCLDeviceTriple("spir64_x86_64"), "opencl-aot", "--help", "")); if (HelpArgs.empty()) { C.getDriver().Diag(diag::err_drv_unsupported_option_argument) @@ -3614,7 +3613,7 @@ static bool hasSYCLDefaultSection(Compilation &C, const StringRef &File) { if (!(IsArchive || isObjectFile(File.str()))) return false; - llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(getDefaultSYCLArch(C))); + llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(getDefaultSYCLArch(C))); // Checking uses -check-section option with the input file, no output // file and the target triple being looked for. const char *Targets = @@ -3821,7 +3820,7 @@ bool Driver::checkForSYCLDefaultDevice(Compilation &C, // or if -fsycl-targets isn't passed (that implies default device) if (const Arg *A = Args.getLastArg(options::OPT_fsycl_targets_EQ)) { for (const char *Val : A->getValues()) { - llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val)); + llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val)); if ((TT.isSPIROrSPIRV()) && TT.getSubArch() == llvm::Triple::NoSubArch) // Default triple found return false; @@ -6303,7 +6302,7 @@ class OffloadingActionBuilder final { // There are a few different variants for FPGA, if we see one, just // use the default FPGA triple to reduce possible match confusion. if (Arch.compare(0, 4, "fpga") == 0) - Arch = C.getDriver().MakeSYCLDeviceTriple("spir64_fpga").str(); + Arch = C.getDriver().getSYCLDeviceTriple("spir64_fpga").str(); if (std::find(UniqueSections.begin(), UniqueSections.end(), Arch) == UniqueSections.end()) @@ -6460,8 +6459,9 @@ class OffloadingActionBuilder final { // Unrecognized, we have already diagnosed this earlier; skip. continue; // Add the proper -device value to the list. - GpuArchList.emplace_back(C.getDriver().MakeSYCLDeviceTriple( - "spir64_gen"), ValidDevice->data()); + GpuArchList.emplace_back( + C.getDriver().getSYCLDeviceTriple("spir64_gen"), + ValidDevice->data()); UserTargetName = "spir64_gen"; } else if (auto ValidDevice = gen::isGPUTarget(Val)) { @@ -6470,7 +6470,7 @@ class OffloadingActionBuilder final { continue; // Add the proper -device value to the list. GpuArchList.emplace_back( - C.getDriver().MakeSYCLDeviceTriple("nvptx64-nvidia-cuda"), + C.getDriver().getSYCLDeviceTriple("nvptx64-nvidia-cuda"), ValidDevice->data()); UserTargetName = "nvptx64-nvidia-cuda"; } else if (auto ValidDevice = gen::isGPUTarget(Val)) { @@ -6479,7 +6479,7 @@ class OffloadingActionBuilder final { continue; // Add the proper -device value to the list. GpuArchList.emplace_back( - C.getDriver().MakeSYCLDeviceTriple("amdgcn-amd-amdhsa"), + C.getDriver().getSYCLDeviceTriple("amdgcn-amd-amdhsa"), ValidDevice->data()); UserTargetName = "amdgcn-amd-amdhsa"; } else if (Val == "native_cpu") { @@ -6490,7 +6490,7 @@ class OffloadingActionBuilder final { continue; } - llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val)); + llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val)); std::string NormalizedName = TT.normalize(); // Make sure we don't have a duplicate triple. @@ -6503,7 +6503,7 @@ class OffloadingActionBuilder final { FoundNormalizedTriples[NormalizedName] = Val; SYCLTripleList.push_back( - C.getDriver().MakeSYCLDeviceTriple(UserTargetName)); + C.getDriver().getSYCLDeviceTriple(UserTargetName)); if (TT.getSubArch() == llvm::Triple::SPIRSubArch_fpga) SYCLfpgaTriple = true; // For user specified spir64_gen, add an empty device value as a @@ -6567,7 +6567,7 @@ class OffloadingActionBuilder final { // -fsycl -fintelfpga implies spir64_fpga const char *SYCLTargetArch = SYCLfpga ? "spir64_fpga" : getDefaultSYCLArch(C); - llvm::Triple TT = C.getDriver().MakeSYCLDeviceTriple(SYCLTargetArch); + llvm::Triple TT = C.getDriver().getSYCLDeviceTriple(SYCLTargetArch); auto TCIt = llvm::find_if( ToolChains, [&](auto &TC) { return TT == TC->getTriple(); }); assert(TCIt != ToolChains.end() && @@ -8372,14 +8372,14 @@ Action *Driver::ConstructPhaseAction( return C.MakeAction(Input, Output); } if (Args.hasArg(options::OPT_emit_llvm) || - ((TargetDeviceOffloadKind == Action::OFK_SYCL && - C.getDriver().getUseNewOffloadingDriver()) || - (((Input->getOffloadingToolChain() && - Input->getOffloadingToolChain()->getTriple().isAMDGPU()) || - TargetDeviceOffloadKind == Action::OFK_HIP) && - (Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, - false) || - TargetDeviceOffloadKind == Action::OFK_OpenMP)))) { + (TargetDeviceOffloadKind == Action::OFK_SYCL && + C.getDriver().getUseNewOffloadingDriver()) || + (((Input->getOffloadingToolChain() && + Input->getOffloadingToolChain()->getTriple().isAMDGPU()) || + TargetDeviceOffloadKind == Action::OFK_HIP) && + (Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, + false) || + TargetDeviceOffloadKind == Action::OFK_OpenMP))) { types::ID Output = Args.hasArg(options::OPT_S) && (TargetDeviceOffloadKind == Action::OFK_None || diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 9a0c1fd76c9d3..ba4ab01be4def 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1660,7 +1660,7 @@ llvm::opt::DerivedArgList *ToolChain::TranslateOffloadTargetArgs( A->getOption().matches(options::OPT_Xsycl_frontend); if (A->getOption().matches(options::OPT_Xsycl_frontend_EQ)) { // Passing device args: -Xsycl-target-frontend= -opt=val. - if (getDriver().MakeSYCLDeviceTriple(A->getValue(0)) == getTriple()) + if (getDriver().getSYCLDeviceTriple(A->getValue(0)) == getTriple()) Index = Args.getBaseArgs().MakeIndex(A->getValue(1)); else continue; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index e5e888aa64ee2..bb3492887c8e9 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1150,10 +1150,10 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA, Args.AddLastArg(CmdArgs, options::OPT_MP); Args.AddLastArg(CmdArgs, options::OPT_MV); - // Add offload include arguments specific for CUDA/HIP. This must happen + // Add offload include arguments specific for CUDA/HIP/SYCL. This must happen // before we -I or -include anything else, because we must pick up the - // CUDA/HIP headers from the particular CUDA/ROCm installation, rather than - // from e.g. /usr/local/include. + // CUDA/HIP/SYCL headers from the particular CUDA/ROCm/SYCL installation, + // rather than from e.g. /usr/local/include. if (JA.isOffloading(Action::OFK_Cuda)) getToolChain().AddCudaIncludeArgs(Args, CmdArgs); if (JA.isOffloading(Action::OFK_HIP)) @@ -5518,135 +5518,210 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Arg *SYCLStdArg = Args.getLastArg(options::OPT_sycl_std_EQ); - if (IsSYCLDevice) { - if (Triple.isNVPTX()) { - StringRef GPUArchName = JA.getOffloadingArch(); - // TODO: Once default arch is moved to at least SM_53, empty arch should - // also result in the flag added. - if (!GPUArchName.empty() && - StringToOffloadArch(GPUArchName) >= OffloadArch::SM_53) - CmdArgs.push_back("-fnative-half-type"); - } - // Pass the triple of host when doing SYCL - llvm::Triple AuxT = C.getDefaultToolChain().getTriple(); - std::string NormalizedTriple = AuxT.normalize(); - CmdArgs.push_back("-aux-triple"); - CmdArgs.push_back(Args.MakeArgString(NormalizedTriple)); + if (IsSYCL) { + if (IsSYCLDevice) { + if (Triple.isNVPTX()) { + StringRef GPUArchName = JA.getOffloadingArch(); + // TODO: Once default arch is moved to at least SM_53, empty arch should + // also result in the flag added. + if (!GPUArchName.empty() && + StringToOffloadArch(GPUArchName) >= OffloadArch::SM_53) + CmdArgs.push_back("-fnative-half-type"); + } + // Pass the triple of host when doing SYCL + llvm::Triple AuxT = C.getDefaultToolChain().getTriple(); + std::string NormalizedTriple = AuxT.normalize(); + CmdArgs.push_back("-aux-triple"); + CmdArgs.push_back(Args.MakeArgString(NormalizedTriple)); + + // We want to compile sycl kernels. + CmdArgs.push_back("-fsycl-is-device"); + CmdArgs.push_back("-fdeclare-spirv-builtins"); + + // Default value for FPGA is false, for all other targets is true. + if (!Args.hasFlag(options::OPT_fsycl_early_optimizations, + options::OPT_fno_sycl_early_optimizations, + !IsFPGASYCLOffloadDevice)) + CmdArgs.push_back("-fno-sycl-early-optimizations"); + else if (RawTriple.isSPIROrSPIRV()) { + // Set `sycl-opt` option to configure LLVM passes for SPIR/SPIR-V target + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-sycl-opt"); + } + if (IsSYCLNativeCPU) { + CmdArgs.push_back("-fsycl-is-native-cpu"); + CmdArgs.push_back("-D"); + CmdArgs.push_back("__SYCL_NATIVE_CPU__"); + CmdArgs.push_back("-fno-autolink"); + } - // We want to compile sycl kernels. - CmdArgs.push_back("-fsycl-is-device"); - CmdArgs.push_back("-fdeclare-spirv-builtins"); - - // Default value for FPGA is false, for all other targets is true. - if (!Args.hasFlag(options::OPT_fsycl_early_optimizations, - options::OPT_fno_sycl_early_optimizations, - !IsFPGASYCLOffloadDevice)) - CmdArgs.push_back("-fno-sycl-early-optimizations"); - else if (RawTriple.isSPIROrSPIRV()) { - // Set `sycl-opt` option to configure LLVM passes for SPIR/SPIR-V target - CmdArgs.push_back("-mllvm"); - CmdArgs.push_back("-sycl-opt"); - } - if (IsSYCLNativeCPU) { - CmdArgs.push_back("-fsycl-is-native-cpu"); - CmdArgs.push_back("-D"); - CmdArgs.push_back("__SYCL_NATIVE_CPU__"); - CmdArgs.push_back("-fno-autolink"); - } - - // Turn on Dead Parameter Elimination Optimization with early optimizations - // TODO: Enable DAE by default without the Optimization level check in the - // driver. The enabling can be done in CodeGenOpt, and we can pass an - // option to explicitly disable/disable here. - if (!(RawTriple.isAMDGCN()) && - Args.hasFlag(options::OPT_fsycl_dead_args_optimization, - options::OPT_fno_sycl_dead_args_optimization, - isSYCLOptimizationO2orHigher(Args))) - CmdArgs.push_back("-fenable-sycl-dae"); - if (IsWindowsMSVC) { - CmdArgs.push_back("-fms-extensions"); - CmdArgs.push_back("-fms-compatibility"); - CmdArgs.push_back("-fdelayed-template-parsing"); - VersionTuple MSVT = C.getDefaultToolChain().computeMSVCVersion(&D, Args); - if (!MSVT.empty()) - CmdArgs.push_back(Args.MakeArgString("-fms-compatibility-version=" + - MSVT.getAsString())); - else { - const char *LowestMSVCSupported = "19.16.27023"; // VS2017 v15.9 - CmdArgs.push_back(Args.MakeArgString( - Twine("-fms-compatibility-version=") + LowestMSVCSupported)); + // Turn on Dead Parameter Elimination Optimization with early + // optimizations + // TODO: Enable DAE by default without the Optimization level check in the + // driver. The enabling can be done in CodeGenOpt, and we can pass an + // option to explicitly disable/disable here. + if (!(RawTriple.isAMDGCN()) && + Args.hasFlag(options::OPT_fsycl_dead_args_optimization, + options::OPT_fno_sycl_dead_args_optimization, + isSYCLOptimizationO2orHigher(Args))) + CmdArgs.push_back("-fenable-sycl-dae"); + if (IsWindowsMSVC) { + CmdArgs.push_back("-fms-extensions"); + CmdArgs.push_back("-fms-compatibility"); + CmdArgs.push_back("-fdelayed-template-parsing"); + VersionTuple MSVT = + C.getDefaultToolChain().computeMSVCVersion(&D, Args); + if (!MSVT.empty()) + CmdArgs.push_back(Args.MakeArgString("-fms-compatibility-version=" + + MSVT.getAsString())); + else { + const char *LowestMSVCSupported = "19.16.27023"; // VS2017 v15.9 + CmdArgs.push_back(Args.MakeArgString( + Twine("-fms-compatibility-version=") + LowestMSVCSupported)); + } } - } - if (Args.hasFlag(options::OPT_fsycl_allow_func_ptr, - options::OPT_fno_sycl_allow_func_ptr, false)) { - CmdArgs.push_back("-fsycl-allow-func-ptr"); - } + if (Args.hasFlag(options::OPT_fsycl_allow_func_ptr, + options::OPT_fno_sycl_allow_func_ptr, false)) { + CmdArgs.push_back("-fsycl-allow-func-ptr"); + } - Args.AddLastArg(CmdArgs, options::OPT_fsycl_decompose_functor, - options::OPT_fno_sycl_decompose_functor); + Args.AddLastArg(CmdArgs, options::OPT_fsycl_decompose_functor, + options::OPT_fno_sycl_decompose_functor); + + // Forward -fsycl-instrument-device-code option to cc1. This option will + // only be used for SPIR/SPIR-V based targets. + if (Triple.isSPIROrSPIRV()) + if (Args.hasFlag(options::OPT_fsycl_instrument_device_code, + options::OPT_fno_sycl_instrument_device_code, false)) + CmdArgs.push_back("-fsycl-instrument-device-code"); + + if (!SYCLStdArg) { + // The user had not pass SYCL version, thus we'll employ no-sycl-strict + // to allow address-space unqualified pointers in function params/return + // along with marking the same function with explicit SYCL_EXTERNAL + CmdArgs.push_back("-Wno-sycl-strict"); + } - // Forward -fsycl-instrument-device-code option to cc1. This option will - // only be used for SPIR/SPIR-V based targets. - if (Triple.isSPIROrSPIRV()) - if (Args.hasFlag(options::OPT_fsycl_instrument_device_code, - options::OPT_fno_sycl_instrument_device_code, false)) - CmdArgs.push_back("-fsycl-instrument-device-code"); + // Set O2 optimization level by default + if (!Args.getLastArg(options::OPT_O_Group)) + CmdArgs.push_back("-O2"); - if (!SYCLStdArg) { - // The user had not pass SYCL version, thus we'll employ no-sycl-strict - // to allow address-space unqualified pointers in function params/return - // along with marking the same function with explicit SYCL_EXTERNAL - CmdArgs.push_back("-Wno-sycl-strict"); - } + // Add the integration header option to generate the header. + StringRef Header(D.getIntegrationHeader(Input.getBaseInput())); + if (!Header.empty()) { + SmallString<128> HeaderOpt("-fsycl-int-header="); + HeaderOpt.append(Header); + CmdArgs.push_back(Args.MakeArgString(HeaderOpt)); + } - // Set O2 optimization level by default - if (!Args.getLastArg(options::OPT_O_Group)) - CmdArgs.push_back("-O2"); + if (!Args.hasArg(options::OPT_fno_sycl_use_footer)) { + // Add the integration footer option to generated the footer. + StringRef Footer(D.getIntegrationFooter(Input.getBaseInput())); + if (!Footer.empty()) { + SmallString<128> FooterOpt("-fsycl-int-footer="); + FooterOpt.append(Footer); + CmdArgs.push_back(Args.MakeArgString(FooterOpt)); + } + } - // Add the integration header option to generate the header. - StringRef Header(D.getIntegrationHeader(Input.getBaseInput())); - if (!Header.empty()) { - SmallString<128> HeaderOpt("-fsycl-int-header="); - HeaderOpt.append(Header); - CmdArgs.push_back(Args.MakeArgString(HeaderOpt)); - } + // Forward -fsycl-default-sub-group-size if in SYCL mode. + Args.AddLastArg(CmdArgs, options::OPT_fsycl_default_sub_group_size); - if (!Args.hasArg(options::OPT_fno_sycl_use_footer)) { - // Add the integration footer option to generated the footer. - StringRef Footer(D.getIntegrationFooter(Input.getBaseInput())); - if (!Footer.empty()) { - SmallString<128> FooterOpt("-fsycl-int-footer="); - FooterOpt.append(Footer); - CmdArgs.push_back(Args.MakeArgString(FooterOpt)); + if (Args.hasArg(options::OPT_fsycl_optimize_non_user_code)) { + const Arg *OArg = Args.getLastArg(options::OPT_O_Group); + if (!OArg || !OArg->getOption().matches(options::OPT_O0)) { + bool isCLMode = C.getDriver().IsCLMode(); + // Linux and Windows have different debug options. + const StringRef Option = isCLMode ? "-Od" : "-O0"; + D.Diag(diag::err_drv_fsycl_wrong_optimization_options) << Option; + } + + CmdArgs.push_back("-fsycl-optimize-non-user-code"); } - } + // Add any predefined macros associated with intel_gpu* type targets + // passed in with -fsycl-targets + // TODO: Macros are populated during device compilations and saved for + // addition to the host compilation. There is no dependence connection + // between device and host where we should be able to use the offloading + // arch to add the macro to the host compile. + auto addTargetMacros = [&](const llvm::Triple &Triple) { + if (!Triple.isSPIR() && !Triple.isNVPTX() && !Triple.isAMDGCN()) + return; + SmallString<64> Macro; + if ((Triple.isSPIR() && + Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen) || + Triple.isNVPTX() || Triple.isAMDGCN()) { + StringRef Device = JA.getOffloadingArch(); + if (!Device.empty() && + !SYCL::gen::getGenDeviceMacro(Device).empty()) { + Macro = "-D"; + Macro += SYCL::gen::getGenDeviceMacro(Device); + } + } else if (Triple.getSubArch() == llvm::Triple::SPIRSubArch_x86_64) + Macro = "-D__SYCL_TARGET_INTEL_X86_64__"; + if (Macro.size()) { + CmdArgs.push_back(Args.MakeArgString(Macro)); + D.addSYCLTargetMacroArg(Args, Macro); + } + }; + addTargetMacros(RawTriple); + } else { + // Add any options that are needed specific to SYCL offload while + // performing the host side compilation. - // Forward -fsycl-default-sub-group-size if in SYCL mode. - Args.AddLastArg(CmdArgs, options::OPT_fsycl_default_sub_group_size); + // Let the front-end host compilation flow know about SYCL offload + // compilation + CmdArgs.push_back("-fsycl-is-host"); - if (Args.hasArg(options::OPT_fsycl_optimize_non_user_code)) { - const Arg *OArg = Args.getLastArg(options::OPT_O_Group); - if (!OArg || !OArg->getOption().matches(options::OPT_O0)) { - bool isCLMode = C.getDriver().IsCLMode(); - // Linux and Windows have different debug options. - const StringRef Option = isCLMode ? "-Od" : "-O0"; - D.Diag(diag::err_drv_fsycl_wrong_optimization_options) << Option; + // Add the -include option to add the integration header + StringRef Header = D.getIntegrationHeader(Input.getBaseInput()); + // Do not add the integration header if we are compiling after the + // integration footer has been applied. Check for the append job + // action to determine this. + if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID && + !Header.empty()) { + // Add the -include-internal-header option to add the integration header + CmdArgs.push_back("-include-internal-header"); + CmdArgs.push_back(Args.MakeArgString(Header)); + // When creating dependency information, filter out the generated + // header file. + CmdArgs.push_back("-dependency-filter"); + CmdArgs.push_back(Args.MakeArgString(Header)); + + // Since this is a host compilation and the integration header is + // included, enable the integration header based diagnostics. + CmdArgs.push_back("-fsycl-enable-int-header-diags"); + } + + StringRef Footer = D.getIntegrationFooter(Input.getBaseInput()); + if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID && + !Args.hasArg(options::OPT_fno_sycl_use_footer) && !Footer.empty()) { + // Add the -include-internal-footer option to add the integration footer + CmdArgs.push_back("-include-internal-footer"); + CmdArgs.push_back(Args.MakeArgString(Footer)); + // When creating dependency information, filter out the generated + // integration footer file. + CmdArgs.push_back("-dependency-filter"); + CmdArgs.push_back(Args.MakeArgString(Footer)); } - CmdArgs.push_back("-fsycl-optimize-non-user-code"); + if (!D.IsCLMode() && IsWindowsMSVC && + !Args.hasArg(options::OPT_fms_runtime_lib_EQ)) { + // SYCL library is guaranteed to work correctly only with dynamic + // MSVC runtime. + CmdArgs.push_back("-D_MT"); + CmdArgs.push_back("-D_DLL"); + } + // Add the SYCL target macro arguments that were generated during the + // device compilation step. + for (auto &Macro : D.getSYCLTargetMacroArgs()) + CmdArgs.push_back(Args.MakeArgString(Macro)); + if (Args.hasArg(options::OPT_fno_sycl_esimd_build_host_code)) + CmdArgs.push_back("-fno-sycl-esimd-build-host-code"); } - } - if (IsSYCL) { // Set options for both host and device - if (Arg *A = Args.getLastArg(options::OPT_fsycl_id_queries_fit_in_int, - options::OPT_fno_sycl_id_queries_fit_in_int)) - A->render(Args, CmdArgs); - - if (Args.hasArg(options::OPT_fpreview_breaking_changes)) - CmdArgs.push_back("-D__INTEL_PREVIEW_BREAKING_CHANGES"); - if (SYCLStdArg) { SYCLStdArg->render(Args, CmdArgs); CmdArgs.push_back("-fsycl-std-layout-kernel-params"); @@ -5655,6 +5730,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-sycl-std=2020"); } + if (Arg *A = Args.getLastArg(options::OPT_fsycl_id_queries_fit_in_int, + options::OPT_fno_sycl_id_queries_fit_in_int)) + A->render(Args, CmdArgs); + + if (Args.hasArg(options::OPT_fpreview_breaking_changes)) + CmdArgs.push_back("-D__INTEL_PREVIEW_BREAKING_CHANGES"); + bool DisableSYCLForceInlineKernelLambda = false; if (Arg *A = Args.getLastArg(options::OPT_O_Group)) DisableSYCLForceInlineKernelLambda = @@ -5731,87 +5813,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fintelfpga"); } - // Add any options that are needed specific to SYCL offload while - // performing the host side compilation. - if (!IsSYCLDevice) { - // Add the -include option to add the integration header - StringRef Header = D.getIntegrationHeader(Input.getBaseInput()); - // Do not add the integration header if we are compiling after the - // integration footer has been applied. Check for the append job - // action to determine this. - if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID && - !Header.empty()) { - // Add the -include-internal-header option to add the integration header - CmdArgs.push_back("-include-internal-header"); - CmdArgs.push_back(Args.MakeArgString(Header)); - // When creating dependency information, filter out the generated - // header file. - CmdArgs.push_back("-dependency-filter"); - CmdArgs.push_back(Args.MakeArgString(Header)); - - // Since this is a host compilation and the integration header is - // included, enable the integration header based diagnostics. - CmdArgs.push_back("-fsycl-enable-int-header-diags"); - } - - StringRef Footer = D.getIntegrationFooter(Input.getBaseInput()); - if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID && - !Args.hasArg(options::OPT_fno_sycl_use_footer) && !Footer.empty()) { - // Add the -include-internal-footer option to add the integration footer - CmdArgs.push_back("-include-internal-footer"); - CmdArgs.push_back(Args.MakeArgString(Footer)); - // When creating dependency information, filter out the generated - // integration footer file. - CmdArgs.push_back("-dependency-filter"); - CmdArgs.push_back(Args.MakeArgString(Footer)); - } - - // Let the FE know we are doing a SYCL offload compilation, but we are - // doing the host pass. - CmdArgs.push_back("-fsycl-is-host"); - - if (!D.IsCLMode() && IsWindowsMSVC && - !Args.hasArg(options::OPT_fms_runtime_lib_EQ)) { - // SYCL library is guaranteed to work correctly only with dynamic - // MSVC runtime. - CmdArgs.push_back("-D_MT"); - CmdArgs.push_back("-D_DLL"); - } - } - // Add any predefined macros associated with intel_gpu* type targets - // passed in with -fsycl-targets - // TODO: Macros are populated during device compilations and saved for - // addition to the host compilation. There is no dependence connection - // between device and host where we should be able to use the offloading - // arch to add the macro to the host compile. - auto addTargetMacros = [&](const llvm::Triple &Triple) { - if (!Triple.isSPIR() && !Triple.isNVPTX() && !Triple.isAMDGCN()) - return; - SmallString<64> Macro; - if ((Triple.isSPIR() && - Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen) || - Triple.isNVPTX() || Triple.isAMDGCN()) { - StringRef Device = JA.getOffloadingArch(); - if (!Device.empty() && !SYCL::gen::getGenDeviceMacro(Device).empty()) { - Macro = "-D"; - Macro += SYCL::gen::getGenDeviceMacro(Device); - } - } else if (Triple.getSubArch() == llvm::Triple::SPIRSubArch_x86_64) - Macro = "-D__SYCL_TARGET_INTEL_X86_64__"; - if (Macro.size()) { - CmdArgs.push_back(Args.MakeArgString(Macro)); - D.addSYCLTargetMacroArg(Args, Macro); - } - }; - if (IsSYCLDevice) - addTargetMacros(RawTriple); - else { - for (auto &Macro : D.getSYCLTargetMacroArgs()) - CmdArgs.push_back(Args.MakeArgString(Macro)); - if (Args.hasArg(options::OPT_fno_sycl_esimd_build_host_code)) - CmdArgs.push_back("-fno-sycl-esimd-build-host-code"); - } - const auto DeviceTraitsMacrosArgs = D.getDeviceTraitsMacrosArgs(); for (const auto &Arg : DeviceTraitsMacrosArgs) { CmdArgs.push_back(Arg); @@ -8650,7 +8651,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } else // Use the default. - TargetInfo += C.getDriver().MakeSYCLDeviceTriple().normalize(); + TargetInfo += C.getDriver().getSYCLDeviceTriple().normalize(); CmdArgs.push_back(Args.MakeArgString(TargetInfo.str())); } @@ -9996,7 +9997,7 @@ void OffloadBundler::ConstructJobMultipleOutputs( TCArgs.hasArg(options::OPT_fsycl_force_target_EQ)) { StringRef Val( TCArgs.getLastArg(options::OPT_fsycl_force_target_EQ)->getValue()); - llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val)); + llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val)); Triples += TT.normalize(); } else Triples += Dep.DependentToolChain->getTriple().normalize(); @@ -10548,7 +10549,7 @@ void OffloadDeps::constructJob(Compilation &C, const JobAction &JA, TCArgs.hasArg(options::OPT_fsycl_force_target_EQ)) { StringRef Val( TCArgs.getLastArg(options::OPT_fsycl_force_target_EQ)->getValue()); - llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val)); + llvm::Triple TT(C.getDriver().getSYCLDeviceTriple(Val)); Targets += TT.normalize(); } else { std::string NormalizedTriple = diff --git a/clang/lib/Driver/ToolChains/SYCL.cpp b/clang/lib/Driver/ToolChains/SYCL.cpp index e310c65a50801..b333bb7b476d6 100644 --- a/clang/lib/Driver/ToolChains/SYCL.cpp +++ b/clang/lib/Driver/ToolChains/SYCL.cpp @@ -1672,16 +1672,16 @@ void SYCLToolChain::TranslateTargetOpt(const llvm::Triple &Triple, if (IsGenTriple) { if (Device != GenDevice && !Device.empty()) continue; - if (getDriver().MakeSYCLDeviceTriple(A->getValue()) != Triple && + if (getDriver().getSYCLDeviceTriple(A->getValue()) != Triple && GenDevice.empty()) // Triples do not match, but only skip when we know we are not // comparing against intel_gpu_* continue; - if (getDriver().MakeSYCLDeviceTriple(A->getValue()) == Triple && + if (getDriver().getSYCLDeviceTriple(A->getValue()) == Triple && !Device.empty()) // Triples match, but we are expecting a specific device to be set. continue; - } else if (getDriver().MakeSYCLDeviceTriple(A->getValue()) != Triple) + } else if (getDriver().getSYCLDeviceTriple(A->getValue()) != Triple) continue; } else if (!OptNoTriple) // Don't worry about any of the other args, we only want to pass what is @@ -1787,7 +1787,7 @@ void SYCLToolChain::AddImpliedTargetArgs(const llvm::Triple &Triple, for (auto *A : Args) { if (!A->getOption().matches(options::OPT_Xsycl_backend_EQ)) continue; - if (getDriver().MakeSYCLDeviceTriple(A->getValue()) == Triple) + if (getDriver().getSYCLDeviceTriple(A->getValue()) == Triple) TargArgs.push_back(A->getValue(1)); } // Check for any -device settings. diff --git a/clang/test/Driver/sycl-int-footer-old-model.cpp b/clang/test/Driver/sycl-int-footer-old-model.cpp index 256a5cee95686..f317d936bef9c 100644 --- a/clang/test/Driver/sycl-int-footer-old-model.cpp +++ b/clang/test/Driver/sycl-int-footer-old-model.cpp @@ -2,19 +2,21 @@ // RUN: %clangxx -fsycl --no-offload-new-driver -I cmdline/dir -include dummy.h %/s -### 2>&1 \ // RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S -DCMDDIR=cmdline/dir // FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"{{.*}} "-include" "dummy.h" -// FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]" +// FOOTER: clang{{.*}} "-fsycl-is-host" +// FOOTER-SAME: "-include-internal-header" "[[INTHEADER]]" // FOOTER-SAME: "-dependency-filter" "[[INTHEADER]]" -// FOOTER-SAME: "-fsycl-is-host"{{.*}} "-main-file-name" "[[SRCFILE:.+\cpp]]" {{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" +// FOOTER-SAME: "-main-file-name" "[[SRCFILE:.+\cpp]]" {{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" /// Preprocessed file creation with integration footer // RUN: %clangxx -fsycl --no-offload-new-driver -E %/s -### 2>&1 \ // RUN: | FileCheck -check-prefix FOOTER_PREPROC_GEN %s // FOOTER_PREPROC_GEN: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}" "-o" "[[PREPROC_DEVICE:.+\.ii]]" -// FOOTER_PREPROC_GEN: clang{{.*}} "-include-internal-header" "[[INTHEADER]]" +// FOOTER_PREPROC_GEN: clang{{.*}} "-fsycl-is-host" +// FOOTER_PREPROC_GEN-SAME: "-include-internal-header" "[[INTHEADER]]" // FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTHEADER]]" // FOOTER_PREPROC_GEN-SAME: "-include-internal-footer" "[[INTFOOTER]]" // FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTFOOTER]]" -// FOOTER_PREPROC_GEN-SAME: "-fsycl-is-host"{{.*}} "-E"{{.*}} "-o" "[[PREPROC_HOST:.+\.ii]]" +// FOOTER_PREPROC_GEN-SAME: "-E"{{.*}} "-o" "[[PREPROC_HOST:.+\.ii]]" /// Preprocessed file use with integration footer // RUN: touch %t.ii @@ -29,7 +31,7 @@ // RUN: | FileCheck -check-prefix NO-FOOTER --implicit-check-not "-fsycl-int-footer" %s // NO-FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-sycl-std={{.*}}" // NO-FOOTER-NOT: append-file -// NO-FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-fsycl-is-host" +// NO-FOOTER: clang{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[INTHEADER]]" /// Check phases without integration footer // RUN: %clangxx -fsycl --no-offload-new-driver -fno-sycl-instrument-device-code -fno-sycl-device-lib=all -fno-sycl-use-footer -target x86_64-unknown-linux-gnu %s -ccc-print-phases 2>&1 \ diff --git a/clang/test/Driver/sycl-int-header-footer.cpp b/clang/test/Driver/sycl-int-header-footer.cpp index 4bddfcfecd92e..8692f29c765e8 100644 --- a/clang/test/Driver/sycl-int-header-footer.cpp +++ b/clang/test/Driver/sycl-int-header-footer.cpp @@ -3,19 +3,21 @@ // RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S -DCMDDIR=cmdline/dir // FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"{{.*}} "-include" "dummy.h" -// FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]" -// FOOTER-SAME: "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" +// FOOTER: clang{{.*}} "-fsycl-is-host" +// FOOTER-SAME: "-include-internal-header" "[[INTHEADER]]" +// FOOTER-SAME: "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" // FOOTER-NOT: "-include-internal-header" "[[INTHEADER]]" /// Preprocessed file creation with integration footer // RUN: %clangxx -fsycl --offload-new-driver -E %/s -### 2>&1 \ // RUN: | FileCheck -check-prefix FOOTER_PREPROC_GEN %s // FOOTER_PREPROC_GEN: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}" "-o" "[[PREPROC_DEVICE:.+\.ii]]" -// FOOTER_PREPROC_GEN: clang{{.*}} "-include-internal-header" "[[INTHEADER]]" +// FOOTER_PREPROC_GEN: clang{{.*}} "-fsycl-is-host" +// FOOTER_PREPROC_GEN-SAME: "-include-internal-header" "[[INTHEADER]]" // FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTHEADER]]" // FOOTER_PREPROC_GEN-SAME: "-include-internal-footer" "[[INTFOOTER]]" // FOOTER_PREPROC_GEN-SAME: "-dependency-filter" "[[INTFOOTER]]" -// FOOTER_PREPROC_GEN-SAME: "-fsycl-is-host"{{.*}} "-E"{{.*}} "-o" "-" +// FOOTER_PREPROC_GEN-SAME: "-E"{{.*}} "-o" "-" /// Preprocessed file use with integration footer // RUN: touch %t.ii @@ -27,7 +29,7 @@ // RUN: %clangxx -fsycl --offload-new-driver -fno-sycl-use-footer %s -### 2>&1 \ // RUN: | FileCheck -check-prefix NO-FOOTER --implicit-check-not "-fsycl-int-footer" %s // NO-FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-sycl-std={{.*}}" -// NO-FOOTER: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-o" +// NO-FOOTER: clang{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[INTHEADER]]" /// Check phases without integration footer // RUN: %clangxx -fsycl --offload-new-driver -fno-sycl-instrument-device-code -fno-sycl-device-lib=all -fno-sycl-use-footer -target x86_64-unknown-linux-gnu %s -ccc-print-phases 2>&1 \ diff --git a/clang/test/Driver/sycl-offload-aot.cpp b/clang/test/Driver/sycl-offload-aot.cpp index 6e1d2a3ed4ade..973f893a753c3 100644 --- a/clang/test/Driver/sycl-offload-aot.cpp +++ b/clang/test/Driver/sycl-offload-aot.cpp @@ -18,7 +18,7 @@ /// Check that -aux-triple is passed with -fintelfpga // RUN: %clang -### -fintelfpga %s 2>&1 \ // RUN: | FileCheck -DARCH=spir64_fpga -check-prefix=CHK-SYCL-FPGA-AUX-TRIPLE %s -// CHK-SYCL-FPGA-AUX-TRIPLE: clang{{.*}} "-cc1" "-triple" "{{.*}}"{{.*}} "-aux-triple" "[[ARCH]]-{{.*}}"{{.*}} "-fsycl-is-host" +// CHK-SYCL-FPGA-AUX-TRIPLE: clang{{.*}} "-cc1" "-triple"{{.*}} "-fsycl-is-host"{{.*}} "-aux-triple" "[[ARCH]]-{{.*}}" /// Check error for -fsycl-targets with bad triple // RUN: not %clang -### -fsycl-targets=spir64_bad-unknown-unknown -fsycl %s 2>&1 \ diff --git a/clang/test/Driver/sycl-offload-intelfpga.cpp b/clang/test/Driver/sycl-offload-intelfpga.cpp index cc57eadff029c..21d62f8c29b92 100644 --- a/clang/test/Driver/sycl-offload-intelfpga.cpp +++ b/clang/test/Driver/sycl-offload-intelfpga.cpp @@ -24,7 +24,7 @@ // RUN: %clangxx -### -fintelfpga %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-HOST-DEVICE %s // CHK-HOST-DEVICE: clang{{.*}} "-cc1"{{.*}} "-fsycl-is-device"{{.*}} "-fintelfpga" -// CHK-HOST-DEVICE: clang{{.*}} "-cc1"{{.*}} "-fintelfpga"{{.*}} "-fsycl-is-host" +// CHK-HOST-DEVICE: clang{{.*}} "-cc1"{{.*}} "-fsycl-is-host"{{.*}} "-fintelfpga" /// FPGA target implies -fsycl-range-rounding=disable // RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fintelfpga %s 2>&1 \ @@ -32,7 +32,7 @@ // RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-RANGE-ROUNDING %s // CHK-RANGE-ROUNDING: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-range-rounding=disable" -// CHK-RANGE-ROUNDING: clang{{.*}} "-fsycl-range-rounding=disable"{{.*}} "-fsycl-is-host" +// CHK-RANGE-ROUNDING: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-range-rounding=disable" /// FPGA target implies -emit-only-kernels-as-entry-points in sycl-post-link // RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fintelfpga %s 2>&1 \ @@ -45,7 +45,7 @@ // RUN: %clangxx -### -target x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64_fpga-unknown-unknown,spir64_gen-unknown-unknown %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHK-RANGE-ROUNDING-MULTI %s // CHK-RANGE-ROUNDING-MULTI: clang{{.*}} "-triple" "spir64_gen-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-range-rounding=disable" -// CHK-RANGE-ROUNDING-MULTI: clang{{.*}} "-fsycl-range-rounding=disable"{{.*}} "-fsycl-is-host" +// CHK-RANGE-ROUNDING-MULTI: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-range-rounding=disable"{{.*}} // CHK-RANGE-ROUNDING-MULTI: clang{{.*}} "-triple" "spir64_fpga-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-range-rounding=disable" /// -fintelfpga with -reuse-exe= diff --git a/clang/test/Driver/sycl-offload-new-driver.c b/clang/test/Driver/sycl-offload-new-driver.c index e0785e7ed178d..fbadad2863360 100644 --- a/clang/test/Driver/sycl-offload-new-driver.c +++ b/clang/test/Driver/sycl-offload-new-driver.c @@ -27,7 +27,7 @@ // RUN: %clangxx -### --target=x86_64-unknown-linux-gnu -fsycl -fsycl-targets=spir64 --offload-new-driver %s 2>&1 | FileCheck -check-prefix=CHK-FLOW %s // CHK-FLOW: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown" "-aux-triple" "x86_64-unknown-linux-gnu" "-fsycl-is-device" {{.*}} "-fsycl-int-header=[[HEADER:.*]].h" "-fsycl-int-footer=[[FOOTER:.*]].h" {{.*}} "--offload-new-driver" {{.*}} "-o" "[[CC1DEVOUT:.*]]" "-x" "c++" "[[INPUT:.*]]" // CHK-FLOW-NEXT: clang-offload-packager{{.*}} "-o" "[[PACKOUT:.*]]" "--image=file=[[CC1DEVOUT]],triple=spir64-unknown-unknown,arch=,kind=sycl{{.*}}" -// CHK-FLOW-NEXT: clang{{.*}} "-cc1" "-triple" "x86_64-unknown-linux-gnu" {{.*}} "-include-internal-header" "[[HEADER]].h" "-dependency-filter" "[[HEADER]].h" {{.*}} "-include-internal-footer" "[[FOOTER]].h" "-dependency-filter" "[[FOOTER]].h" "-fsycl-is-host"{{.*}} "--offload-new-driver" {{.*}} "-fembed-offload-object=[[PACKOUT]]" {{.*}} "-o" "[[CC1FINALOUT:.*]]" "-x" "c++" "[[INPUT]]" +// CHK-FLOW-NEXT: clang{{.*}} "-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[HEADER]].h" "-dependency-filter" "[[HEADER]].h" {{.*}} "-include-internal-footer" "[[FOOTER]].h" "-dependency-filter" "[[FOOTER]].h"{{.*}} "--offload-new-driver" {{.*}} "-fembed-offload-object=[[PACKOUT]]" {{.*}} "-o" "[[CC1FINALOUT:.*]]" "-x" "c++" "[[INPUT]]" // CHK-FLOW-NEXT: clang-linker-wrapper{{.*}} "--host-triple=x86_64-unknown-linux-gnu"{{.*}} "--linker-path={{.*}}/ld" {{.*}} "[[CC1FINALOUT]]" /// Verify options passed to clang-linker-wrapper diff --git a/clang/test/Driver/sycl-offload-save-temps-old-model.cpp b/clang/test/Driver/sycl-offload-save-temps-old-model.cpp index 8fab2697a290e..eba3d6cbe4814 100644 --- a/clang/test/Driver/sycl-offload-save-temps-old-model.cpp +++ b/clang/test/Driver/sycl-offload-save-temps-old-model.cpp @@ -9,7 +9,7 @@ // RUN: | FileCheck %s --check-prefixes=CHK-FSYCL-SAVE-TEMPS,CHK-FSYCL-SAVE-TEMPS-CONFL // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-device"{{.*}} "-o" "[[DEVICE_BASE_NAME:[a-z0-9-]+]].ii" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[HEADER_NAME:.+\-header.+\.h]]" "-fsycl-int-footer={{.*}}"{{.*}} "-o" "[[DEVICE_BASE_NAME]].bc"{{.*}} "[[DEVICE_BASE_NAME]].ii" -// CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-include-internal-header" "[[HEADER_NAME]]"{{.*}} "-fsycl-is-host"{{.*}} "-o" "[[HOST_BASE_NAME:[a-z0-9_-]+]].ii" +// CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[HEADER_NAME]]"{{.*}} "-o" "[[HOST_BASE_NAME:[a-z0-9_-]+]].ii" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-o" "[[HOST_BASE_NAME:.*]].bc"{{.*}} "[[HOST_BASE_NAME:[a-z0-9_-]+]].ii" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-o" "[[HOST_BASE_NAME:.*]].s"{{.*}} "[[HOST_BASE_NAME]].bc" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-o" "[[HOST_BASE_NAME:.*]].o"{{.*}} "[[HOST_BASE_NAME]].s" diff --git a/clang/test/Driver/sycl-offload-save-temps.cpp b/clang/test/Driver/sycl-offload-save-temps.cpp index 560d7d6d7da73..034b43ffe54ef 100644 --- a/clang/test/Driver/sycl-offload-save-temps.cpp +++ b/clang/test/Driver/sycl-offload-save-temps.cpp @@ -10,7 +10,7 @@ // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-device"{{.*}} "-o" "[[DEVICE_BASE_NAME:[a-z0-9-]+]].ii" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[HEADER_NAME:.+\-header.+\.h]]" "-fsycl-int-footer={{.*}}"{{.*}} "-o" "[[DEVICE_BASE_NAME]].bc"{{.*}} "[[DEVICE_BASE_NAME]].ii" // CHK-FSYCL-SAVE-TEMPS: clang-offload-packager{{.*}} -// CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-include-internal-header" "[[HEADER_NAME]]"{{.*}} "-fsycl-is-host"{{.*}} "-o" "[[HOST_BASE_NAME:[a-z0-9_-]+]].ii" +// CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[HEADER_NAME]]"{{.*}} "-o" "[[HOST_BASE_NAME:[a-z0-9_-]+]].ii" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-o" "[[HOST_BASE_NAME:.*]].bc"{{.*}} "[[HOST_BASE_NAME:[a-z0-9_-]+]].ii" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-o" "[[HOST_BASE_NAME:.*]].s"{{.*}} "[[HOST_BASE_NAME]].bc" // CHK-FSYCL-SAVE-TEMPS: clang{{.*}} "-o" "[[HOST_BASE_NAME:.*]].o"{{.*}} "[[HOST_BASE_NAME]].s" diff --git a/clang/test/Driver/sycl-preprocess-old-model.cpp b/clang/test/Driver/sycl-preprocess-old-model.cpp index 446731cda3bfe..08c93a154d3ee 100644 --- a/clang/test/Driver/sycl-preprocess-old-model.cpp +++ b/clang/test/Driver/sycl-preprocess-old-model.cpp @@ -7,7 +7,7 @@ // RUN: | FileCheck -check-prefix PREPROC_ONLY %s // PREPROC_ONLY: clang{{.*}} "-fsycl-is-device"{{.*}} "-E"{{.*}} "-o" "[[DEVICE_OUT:.+\.ii]]" // PREPROC_ONLY: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\.h]]"{{.*}} "-fsyntax-only" -// PREPROC_ONLY: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-include-internal-footer" "[[INTFOOTER]]"{{.*}} "-fsycl-is-host"{{.*}} "-o" "[[HOST_OUT:.+\.ii]]" +// PREPROC_ONLY: clang{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-include-internal-footer" "[[INTFOOTER]]"{{.*}} "-o" "[[HOST_OUT:.+\.ii]]" /// When compiling from preprocessed file, no integration header is expected // RUN: touch %t.ii diff --git a/clang/test/Driver/sycl-preprocess.cpp b/clang/test/Driver/sycl-preprocess.cpp index e8975e7370387..57fe2fbc35270 100644 --- a/clang/test/Driver/sycl-preprocess.cpp +++ b/clang/test/Driver/sycl-preprocess.cpp @@ -6,7 +6,7 @@ // RUN: %clang_cl -fsycl --offload-new-driver -P -Fi%t_output.ii %s -### 2>&1 \ // RUN: | FileCheck -check-prefix PREPROC_ONLY %s // PREPROC_ONLY: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\.h]]"{{.*}} "-E" -// PREPROC_ONLY: clang{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-include-internal-footer" "[[INTFOOTER]]"{{.*}} "-fsycl-is-host"{{.*}} "-o" "[[HOST_OUT:.+\.ii]]" +// PREPROC_ONLY: clang{{.*}} "-fsycl-is-host"{{.*}} "-include-internal-header" "[[INTHEADER]]"{{.*}} "-include-internal-footer" "[[INTFOOTER]]"{{.*}} "-o" "[[HOST_OUT:.+\.ii]]" /// When compiling from preprocessed file, no integration header is expected // RUN: touch %t.ii diff --git a/clang/test/Driver/sycl-unique-prefix-old-model.cpp b/clang/test/Driver/sycl-unique-prefix-old-model.cpp index 3b0060071946a..f4fdf7442758d 100644 --- a/clang/test/Driver/sycl-unique-prefix-old-model.cpp +++ b/clang/test/Driver/sycl-unique-prefix-old-model.cpp @@ -5,14 +5,14 @@ // RUN: | FileCheck -check-prefix=CHECK_PREFIX %s // CHECK_PREFIX: clang{{.*}} "-triple" "spir64-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX1:uid([A-z0-9]){16}]]"{{.*}} "{{.*}}_file1.cpp" // CHECK_PREFIX: clang{{.*}} "-triple" "spir64_gen-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX1]]"{{.*}} "{{.*}}_file1.cpp" -// CHECK_PREFIX: clang{{.*}} "-fsycl-unique-prefix=[[PREFIX1]]"{{.*}} "-fsycl-is-host"{{.*}} "{{.*}}_file1.cpp" +// CHECK_PREFIX: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-unique-prefix=[[PREFIX1]]"{{.*}} "{{.*}}_file1.cpp" // CHECK_PREFIX: clang{{.*}} "-triple" "spir64-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX2:uid([A-z0-9]){16}]]"{{.*}} "{{.*}}_file2.cpp" // CHECK_PREFIX: clang{{.*}} "-triple" "spir64_gen-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX2]]"{{.*}} "{{.*}}_file2.cpp" -// CHECK_PREFIX: clang{{.*}} "-fsycl-unique-prefix=[[PREFIX2]]"{{.*}} "-fsycl-is-host"{{.*}} "{{.*}}_file2.cpp" +// CHECK_PREFIX: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-unique-prefix=[[PREFIX2]]"{{.*}} "{{.*}}_file2.cpp" /// Check for prefix with preprocessed input // RUN: touch %t.ii // RUN: %clangxx -fsycl --no-offload-new-driver -c %t.ii -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK_PREFIX_II %s // CHECK_PREFIX_II: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX:uid([A-z0-9]){16}]]"{{.*}} "{{.*}}.ii" -// CHECK_PREFIX_II: clang{{.*}} "-fsycl-unique-prefix=[[PREFIX]]"{{.*}} "-fsycl-is-host"{{.*}} "{{.*}}.ii" +// CHECK_PREFIX_II: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-unique-prefix=[[PREFIX]]"{{.*}} "{{.*}}.ii" diff --git a/clang/test/Driver/sycl-unique-prefix.cpp b/clang/test/Driver/sycl-unique-prefix.cpp index 83f5c26eea811..6f39f96337020 100644 --- a/clang/test/Driver/sycl-unique-prefix.cpp +++ b/clang/test/Driver/sycl-unique-prefix.cpp @@ -5,10 +5,10 @@ // RUN: | FileCheck -check-prefix=CHECK_PREFIX %s // CHECK_PREFIX: clang{{.*}} "-triple" "spir64_gen-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX1:uid([A-z0-9]){16}]]"{{.*}} "{{.*}}_file1.cpp" // CHECK_PREFIX: clang{{.*}} "-triple" "spir64-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX1]]"{{.*}} "{{.*}}_file1.cpp" -// CHECK_PREFIX: clang{{.*}} "-fsycl-unique-prefix=[[PREFIX1]]"{{.*}} "-fsycl-is-host"{{.*}} "{{.*}}_file1.cpp" +// CHECK_PREFIX: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-unique-prefix=[[PREFIX1]]"{{.*}} "{{.*}}_file1.cpp" // CHECK_PREFIX: clang{{.*}} "-triple" "spir64_gen-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX2:uid([A-z0-9]){16}]]"{{.*}} "{{.*}}_file2.cpp" // CHECK_PREFIX: clang{{.*}} "-triple" "spir64-unknown-unknown"{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-unique-prefix=[[PREFIX2]]"{{.*}} "{{.*}}_file2.cpp" -// CHECK_PREFIX: clang{{.*}} "-fsycl-unique-prefix=[[PREFIX2]]"{{.*}} "-fsycl-is-host"{{.*}} "{{.*}}_file2.cpp" +// CHECK_PREFIX: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-unique-prefix=[[PREFIX2]]"{{.*}} "{{.*}}_file2.cpp" /// Check for prefix with preprocessed input /// TODO: preprocessing with the new offloading model does not seem to take @@ -18,4 +18,4 @@ // RUN: touch %t.ii // RUN: %clangxx -fsycl --offload-new-driver -c %t.ii -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK_PREFIX_II %s -// CHECK_PREFIX_II: clang{{.*}} "-fsycl-unique-prefix=[[PREFIX:uid([A-z0-9]){16}]]"{{.*}} "-fsycl-is-host" {{.*}}.ii" +// CHECK_PREFIX_II: clang{{.*}} "-fsycl-is-host"{{.*}} "-fsycl-unique-prefix=[[PREFIX:uid([A-z0-9]){16}]]"{{.*}} "{{.*}}.ii"