Skip to content

Commit fbe951f

Browse files
mdtoguchibader
authored andcommitted
[SYCL] Adjust adding of depfile information for FPGA AOT compilation
There was a problem where the dependency file information was not being passed to aoc when compiling from source. This was due to a file exists check that was being performed before the actual file is generated Also when generating dependency files for FPGA AOT, be sure that each file compiled creates an individual dep file to be processed (do not use -o) Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 349a0d3 commit fbe951f

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,11 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
10741074
} else if (A->getOption().matches(options::OPT_M) ||
10751075
A->getOption().matches(options::OPT_MM)) {
10761076
DepFile = "-";
1077+
} else if (A->getOption().matches(options::OPT_MMD) &&
1078+
Args.hasArg(options::OPT_fintelfpga)) {
1079+
// When generating dependency files for FPGA AOT, the output files will
1080+
// always be named after the source file.
1081+
DepFile = Args.MakeArgString(Twine(getBaseInputStem(Args, Inputs)) + ".d");
10771082
} else {
10781083
DepFile = getDependencyFileName(Args, Inputs);
10791084
C.addFailureResultFile(DepFile, &JA);

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,8 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
297297
continue;
298298
if (types::isSrcFile(Ty) || Ty == types::TY_Object) {
299299
llvm::sys::path::replace_extension(FN, "d");
300-
if (llvm::sys::fs::exists(FN))
301-
FPGADepFiles.push_back(InputInfo(types::TY_Dependencies,
302-
Args.MakeArgString(FN), Args.MakeArgString(FN)));
300+
FPGADepFiles.push_back(InputInfo(types::TY_Dependencies,
301+
Args.MakeArgString(FN), Args.MakeArgString(FN)));
303302
}
304303
}
305304
}

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
/// -fintelfpga implies -g and -MMD
77
// RUN: %clang++ -### -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %s 2>&1 \
88
// RUN: | FileCheck -check-prefix=CHK-TOOLS-INTELFPGA %s
9-
// CHK-TOOLS-INTELFPGA: clang{{.*}} "-dependency-file"
10-
// CHK-TOOLS-INTELFPGA: clang{{.*}} "-debug-info-kind=limited"
9+
// CHK-TOOLS-INTELFPGA: clang{{.*}} "-debug-info-kind=limited" {{.*}} "-dependency-file"
10+
// CHK-TOOLS-INTELFPGA: aoc{{.*}} "-dep-files={{.*}}"
1111

1212
/// -fintelfpga -fsycl-link tests
1313
// RUN: touch %t.o
@@ -91,5 +91,16 @@
9191
// RUN: | FileCheck -check-prefixes=CHK-FPGA-REUSE-EXE %s
9292
// CHK-FPGA-REUSE-EXE: aoc{{.*}} "-o" {{.*}} "-sycl" {{.*}} "-reuse-exe=testing"
9393

94+
/// -fintelfpga dependency file generation test
95+
// RUN: touch %t-1.cpp
96+
// RUN: touch %t-2.cpp
97+
// RUN: %clang++ -### -fsycl -fintelfpga %t-1.cpp %t-2.cpp -o %t.out 2>&1 \
98+
// RUN: | FileCheck -check-prefix=CHK-FPGA-DEP-FILES %s
99+
// RUN: %clang++ -### -fsycl -fintelfpga %t-1.cpp %t-2.cpp 2>&1 \
100+
// RUN: | FileCheck -check-prefix=CHK-FPGA-DEP-FILES %s
101+
// CHK-FPGA-DEP-FILES: clang{{.*}} "-dependency-file" "[[INPUT1:.+\.d]]"
102+
// CHK-FPGA-DEP-FILES: clang{{.*}} "-dependency-file" "[[INPUT2:.+\.d]]"
103+
// CHK-FPGA-DEP-FILES: aoc{{.*}} "-dep-files={{.*}}[[INPUT1]],{{.*}}[[INPUT2]]"
104+
94105
// TODO: SYCL specific fail - analyze and enable
95106
// XFAIL: windows-msvc

0 commit comments

Comments
 (0)