@@ -151,7 +151,7 @@ static std::optional<llvm::module_split::IRSplitMode> SYCLModuleSplitMode;
151
151
152
152
static bool UseSYCLPostLinkTool;
153
153
154
- static SmallString<128 > SPIRVDumpDir ;
154
+ static SmallString<128 > OffloadImageDumpDir ;
155
155
156
156
using OffloadingImage = OffloadBinary::OffloadingImage;
157
157
@@ -923,29 +923,6 @@ static Expected<StringRef> runLLVMToSPIRVTranslation(StringRef File,
923
923
if (Error Err = executeCommands (*LLVMToSPIRVPath, CmdArgs))
924
924
return std::move (Err);
925
925
926
- if (!SPIRVDumpDir.empty ()) {
927
- std::error_code EC =
928
- llvm::sys::fs::create_directory (SPIRVDumpDir, /* IgnoreExisting*/ true );
929
- if (EC)
930
- return createStringError (
931
- EC,
932
- formatv (" failed to create dump directory. path: {0}, error_code: {1}" ,
933
- SPIRVDumpDir, EC.value ()));
934
-
935
- StringRef Sep = llvm::sys::path::get_separator ();
936
- StringRef Path = *TempFileOrErr;
937
- StringRef Filename = Path.rsplit (Sep).second ;
938
- SmallString<128 > CopyPath = SPIRVDumpDir;
939
- CopyPath.append (Filename);
940
- EC = llvm::sys::fs::copy_file (Path, CopyPath);
941
- if (EC)
942
- return createStringError (
943
- EC,
944
- formatv (
945
- " failed to copy file. original: {0}, copy: {1}, error_code: {2}" ,
946
- Path, CopyPath, EC.value ()));
947
- }
948
-
949
926
return *TempFileOrErr;
950
927
}
951
928
@@ -1103,6 +1080,18 @@ wrapSYCLBinariesFromFile(std::vector<module_split::SplitModule> &SplitModules,
1103
1080
RegularTarget = " spir64" ;
1104
1081
1105
1082
for (auto &SI : SplitModules) {
1083
+ if (!OffloadImageDumpDir.empty ()) {
1084
+ StringRef CopyFrom = SI.ModuleFilePath ;
1085
+ SmallString<128 > CopyTo = OffloadImageDumpDir;
1086
+ StringRef Filename = sys::path::filename (CopyFrom);
1087
+ CopyTo.append (Filename);
1088
+ std::error_code EC = sys::fs::copy_file (CopyFrom, CopyTo);
1089
+ if (EC)
1090
+ return createStringError (EC, formatv (" failed to copy file. From: "
1091
+ " {0} to: {1}, error_code: {2}" ,
1092
+ CopyFrom, CopyTo, EC.value ()));
1093
+ }
1094
+
1106
1095
auto MBOrDesc = MemoryBuffer::getFile (SI.ModuleFilePath );
1107
1096
if (!MBOrDesc)
1108
1097
return createFileError (SI.ModuleFilePath , MBOrDesc.getError ());
@@ -2618,13 +2607,11 @@ int main(int Argc, char **Argv) {
2618
2607
2619
2608
if (Args.hasArg (OPT_sycl_dump_device_code_EQ)) {
2620
2609
Arg *A = Args.getLastArg (OPT_sycl_dump_device_code_EQ);
2621
- SmallString< 128 > Dir ( A->getValue () );
2622
- if (Dir .empty ())
2623
- llvm:: sys::path::native (Dir = " ./" );
2610
+ OffloadImageDumpDir = A->getValue ();
2611
+ if (OffloadImageDumpDir .empty ())
2612
+ sys::path::native (OffloadImageDumpDir = " ./" );
2624
2613
else
2625
- Dir.append (llvm::sys::path::get_separator ());
2626
-
2627
- SPIRVDumpDir = Dir;
2614
+ OffloadImageDumpDir.append (sys::path::get_separator ());
2628
2615
}
2629
2616
2630
2617
{
0 commit comments