Skip to content

Commit 070d11c

Browse files
committed
[NFC][Driver][HIP] Expose getTempFile helper in HIPUtility.h
1 parent fee71a3 commit 070d11c

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

clang/lib/Driver/ToolChains/HIPSPV.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@ using namespace clang::driver::tools;
2222
using namespace clang;
2323
using namespace llvm::opt;
2424

25-
// Convenience function for creating temporary file for both modes of
26-
// isSaveTempsEnabled().
27-
static const char *getTempFile(Compilation &C, StringRef Prefix,
28-
StringRef Extension) {
29-
if (C.getDriver().isSaveTempsEnabled()) {
30-
return C.getArgs().MakeArgString(Prefix + "." + Extension);
31-
}
32-
auto TmpFile = C.getDriver().GetTemporaryPath(Prefix, Extension);
33-
return C.addTempFile(C.getArgs().MakeArgString(TmpFile));
34-
}
35-
3625
// Locates HIP pass plugin.
3726
static std::string findPassPlugin(const Driver &D,
3827
const llvm::opt::ArgList &Args) {
@@ -65,7 +54,7 @@ void HIPSPV::Linker::constructLinkAndEmitSpirvCommand(
6554

6655
assert(!Inputs.empty() && "Must have at least one input.");
6756
std::string Name = std::string(llvm::sys::path::stem(Output.getFilename()));
68-
const char *TempFile = getTempFile(C, Name + "-link", "bc");
57+
const char *TempFile = HIP::getTempFile(C, Name + "-link", "bc");
6958

7059
// Link LLVM bitcode.
7160
ArgStringList LinkArgs{};
@@ -93,7 +82,7 @@ void HIPSPV::Linker::constructLinkAndEmitSpirvCommand(
9382
auto PassPluginPath = findPassPlugin(C.getDriver(), Args);
9483
if (!PassPluginPath.empty()) {
9584
const char *PassPathCStr = C.getArgs().MakeArgString(PassPluginPath);
96-
const char *OptOutput = getTempFile(C, Name + "-lower", "bc");
85+
const char *OptOutput = HIP::getTempFile(C, Name + "-lower", "bc");
9786
ArgStringList OptArgs{TempFile, "-load-pass-plugin",
9887
PassPathCStr, "-passes=hip-post-link-passes",
9988
"-o", OptOutput};

clang/lib/Driver/ToolChains/HIPUtility.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,14 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
472472
D.getClangProgramPath(), ClangArgs,
473473
Inputs, Output, D.getPrependArg()));
474474
}
475+
476+
// Convenience function for creating temporary file for both modes of
477+
// isSaveTempsEnabled().
478+
const char *HIP::getTempFile(Compilation &C, StringRef Prefix,
479+
StringRef Extension) {
480+
if (C.getDriver().isSaveTempsEnabled()) {
481+
return C.getArgs().MakeArgString(Prefix + "." + Extension);
482+
}
483+
auto TmpFile = C.getDriver().GetTemporaryPath(Prefix, Extension);
484+
return C.addTempFile(C.getArgs().MakeArgString(TmpFile));
485+
}

clang/lib/Driver/ToolChains/HIPUtility.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace driver {
1616
namespace tools {
1717
namespace HIP {
1818

19+
const char *getTempFile(Compilation &C, StringRef Prefix, StringRef Extension);
20+
1921
// Construct command for creating HIP fatbin.
2022
void constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
2123
StringRef OutputFileName,

0 commit comments

Comments
 (0)