Skip to content

[SYCL][Driver] Fix -save-temps for SYCL compilations #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3270,14 +3270,20 @@ class OffloadingActionBuilder final {
for (Action *&A : SYCLDeviceActions) {
DeviceCompilerInput =
C.MakeAction<CompileJobAction>(A, types::TY_SYCL_Header);
A = C.MakeAction<CompileJobAction>(A, types::TY_LLVM_BC);
}
DA.add(*DeviceCompilerInput, *ToolChains.front(), /*BoundArch=*/nullptr,
Action::OFK_SYCL);
// Clear the input file, it is already a dependence to a host
// action.
DeviceCompilerInput = nullptr;
return ABRT_Success;
}

// Backend/Assemble actions are obsolete for the SYCL device side
if (CurPhase == phases::Backend || CurPhase == phases::Assemble)
return ABRT_Inactive;

// The host only depends on device action in the linking phase, when all
// the device images have to be embedded in the host image.
if (CurPhase == phases::Link) {
Expand Down
17 changes: 15 additions & 2 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5978,16 +5978,29 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// Inputs[1]. Include the header with -include
if (!IsSYCLOffloadDevice && SYCLDeviceInput) {
SmallString<128> RealPath;
#if defined(_WIN32)
// Fixup the header path name in case there are discrepancies in the
// string used for the temporary directory environment variable and
// actual path expectations.
//
// While generating the driver commands, we're most often working
// with non-existing files. The Unix implementation of LLVM's real_path
// returns an empty path for a non-existing file if it's expected to be
// placed in the current directory. This becomes a problem when we're
// saving intermediate compilation results via -save-temps.
// Since the header file path fix-up is Windows-specific, the real_path
// call is not necessary for a Unix-based OS (case-sensitive filesystem).
llvm::sys::fs::real_path(SYCLDeviceInput->getFilename(), RealPath);
#else // _WIN32
RealPath.assign(StringRef(SYCLDeviceInput->getFilename()));
#endif // _WIN32
const char *IntHeaderPath = Args.MakeArgString(RealPath);
CmdArgs.push_back("-include");
CmdArgs.push_back(Args.MakeArgString(RealPath));
CmdArgs.push_back(IntHeaderPath);
// When creating dependency information, filter out the generated
// header file.
CmdArgs.push_back("-dependency-filter");
CmdArgs.push_back(Args.MakeArgString(RealPath));
CmdArgs.push_back(IntHeaderPath);
// Let the FE know we are doing a SYCL offload compilation, but we are
// doing the host pass.
CmdArgs.push_back("-fsycl-is-host");
Expand Down
34 changes: 15 additions & 19 deletions clang/test/Driver/sycl-offload-intelfpga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,12 @@
// CHK-FPGA-LINK-SRC: 8: assembler, {7}, object, (host-sycl)
// CHK-FPGA-LINK-SRC: 9: linker, {8}, archive, (host-sycl)
// CHK-FPGA-LINK-SRC: 10: compiler, {3}, ir, (device-sycl)
// CHK-FPGA-LINK-SRC: 11: backend, {10}, assembler, (device-sycl)
// CHK-FPGA-LINK-SRC: 12: assembler, {11}, object, (device-sycl)
// CHK-FPGA-LINK-SRC: 13: linker, {12}, ir, (device-sycl)
// CHK-FPGA-LINK-SRC: 14: llvm-spirv, {13}, spirv, (device-sycl)
// CHK-FPGA-LINK-SRC: 15: backend-compiler, {14}, fpga_aocr, (device-sycl)
// CHK-FPGA-LINK-SRC: 16: clang-offload-wrapper, {15}, object, (device-sycl)
// CHK-FPGA-LINK-SRC-DEFAULT: 17: offload, "host-sycl (x86_64-unknown-linux-gnu)" {9}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {16}, archive
// CHK-FPGA-LINK-SRC-CL: 17: offload, "host-sycl (x86_64-pc-windows-msvc)" {9}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice-coff)" {16}, archive
// CHK-FPGA-LINK-SRC: 11: linker, {10}, ir, (device-sycl)
// CHK-FPGA-LINK-SRC: 12: llvm-spirv, {11}, spirv, (device-sycl)
// CHK-FPGA-LINK-SRC: 13: backend-compiler, {12}, fpga_aocr, (device-sycl)
// CHK-FPGA-LINK-SRC: 14: clang-offload-wrapper, {13}, object, (device-sycl)
// CHK-FPGA-LINK-SRC-DEFAULT: 15: offload, "host-sycl (x86_64-unknown-linux-gnu)" {9}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {14}, archive
// CHK-FPGA-LINK-SRC-CL: 15: offload, "host-sycl (x86_64-pc-windows-msvc)" {9}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice-coff)" {14}, archive

/// -fintelfpga with -reuse-exe=
// RUN: touch %t.cpp
Expand Down Expand Up @@ -197,17 +195,15 @@
// CHK-FPGA-AOCO-PHASES: 9: assembler, {8}, object, (host-sycl)
// CHK-FPGA-AOCO-PHASES: 10: linker, {0, 9}, image, (host-sycl)
// CHK-FPGA-AOCO-PHASES: 11: compiler, {4}, ir, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 12: backend, {11}, assembler, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 13: assembler, {12}, object, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 14: input, "[[INPUTA]]", archive
// CHK-FPGA-AOCO-PHASES-LIN: 15: clang-offload-unbundler, {14}, object
// CHK-FPGA-AOCO-PHASES-WIN: 15: clang-offload-unbundler, {14}, archive
// CHK-FPGA-AOCO-PHASES: 16: linker, {13, 15}, ir, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 17: llvm-spirv, {16}, spirv, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 18: backend-compiler, {17}, fpga_aocx, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 19: clang-offload-wrapper, {18}, object, (device-sycl)
// CHK-FPGA-AOCO-PHASES-LIN: 20: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {19}, image
// CHK-FPGA-AOCO-PHASES-WIN: 20: offload, "host-sycl (x86_64-pc-windows-msvc)" {10}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice-coff)" {19}, image
// CHK-FPGA-AOCO-PHASES: 12: input, "[[INPUTA]]", archive
// CHK-FPGA-AOCO-PHASES-LIN: 13: clang-offload-unbundler, {12}, object
// CHK-FPGA-AOCO-PHASES-WIN: 13: clang-offload-unbundler, {12}, archive
// CHK-FPGA-AOCO-PHASES: 14: linker, {11, 13}, ir, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 15: llvm-spirv, {14}, spirv, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 16: backend-compiler, {15}, fpga_aocx, (device-sycl)
// CHK-FPGA-AOCO-PHASES: 17: clang-offload-wrapper, {16}, object, (device-sycl)
// CHK-FPGA-AOCO-PHASES-LIN: 18: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {17}, image
// CHK-FPGA-AOCO-PHASES-WIN: 18: offload, "host-sycl (x86_64-pc-windows-msvc)" {10}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice-coff)" {17}, image

/// aoco test, checking tools
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga -foffload-static-lib=%t_aoco.a -### %s 2>&1 \
Expand Down
14 changes: 6 additions & 8 deletions clang/test/Driver/sycl-offload-static-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@
// FOFFLOAD_STATIC_LIB_SRC: 9: assembler, {8}, object, (host-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 10: linker, {0, 9}, image, (host-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 11: compiler, {4}, ir, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 12: backend, {11}, assembler, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 13: assembler, {12}, object, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 14: input, "[[INPUTA]]", archive
// FOFFLOAD_STATIC_LIB_SRC: 15: clang-offload-unbundler, {14}, object
// FOFFLOAD_STATIC_LIB_SRC: 16: linker, {13, 15}, ir, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 17: llvm-spirv, {16}, spirv, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 18: clang-offload-wrapper, {17}, object, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 19: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (spir64-unknown-unknown-sycldevice)" {18}, image
// FOFFLOAD_STATIC_LIB_SRC: 12: input, "[[INPUTA]]", archive
// FOFFLOAD_STATIC_LIB_SRC: 13: clang-offload-unbundler, {12}, object
// FOFFLOAD_STATIC_LIB_SRC: 14: linker, {11, 13}, ir, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 15: llvm-spirv, {14}, spirv, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 16: clang-offload-wrapper, {15}, object, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 17: offload, "host-sycl (x86_64-unknown-linux-gnu)" {10}, "device-sycl (spir64-unknown-unknown-sycldevice)" {16}, image

/// ###########################################################################

Expand Down
14 changes: 6 additions & 8 deletions clang/test/Driver/sycl-offload-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@
// FOFFLOAD_STATIC_LIB_SRC: 9: assembler, {8}, object, (host-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 10: linker, {0, 9}, image, (host-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 11: compiler, {4}, ir, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 12: backend, {11}, assembler, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 13: assembler, {12}, object, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 14: input, "[[INPUTLIB]]", archive
// FOFFLOAD_STATIC_LIB_SRC: 15: clang-offload-unbundler, {14}, archive
// FOFFLOAD_STATIC_LIB_SRC: 16: linker, {13, 15}, ir, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 17: llvm-spirv, {16}, spirv, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 18: clang-offload-wrapper, {17}, object, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 19: offload, "host-sycl (x86_64-pc-windows-msvc)" {10}, "device-sycl (spir64-unknown-unknown-sycldevice{{(-coff)?}})" {18}, image
// FOFFLOAD_STATIC_LIB_SRC: 12: input, "[[INPUTLIB]]", archive
// FOFFLOAD_STATIC_LIB_SRC: 13: clang-offload-unbundler, {12}, archive
// FOFFLOAD_STATIC_LIB_SRC: 14: linker, {11, 13}, ir, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 15: llvm-spirv, {14}, spirv, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 16: clang-offload-wrapper, {15}, object, (device-sycl)
// FOFFLOAD_STATIC_LIB_SRC: 17: offload, "host-sycl (x86_64-pc-windows-msvc)" {10}, "device-sycl (spir64-unknown-unknown-sycldevice{{(-coff)?}})" {16}, image

/// ###########################################################################

Expand Down
Loading