yaxunl updated this revision to Diff 503218.
yaxunl edited the summary of this revision.
yaxunl added a reviewer: keith.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145509/new/
https://reviews.llvm.org/D145509
Files:
clang/include/clang/Driver/Driver.h
clang/lib/Driver/Driver.cpp
clang/test/Driver/hip-link-bc-to-bc.hip
clang/test/Driver/hip-temps-linux.hip
clang/test/Driver/hip-temps-windows.hip
Index: clang/test/Driver/hip-temps-windows.hip
===================================================================
--- /dev/null
+++ clang/test/Driver/hip-temps-windows.hip
@@ -0,0 +1,17 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: system-windows
+
+// Check no temporary files or directores are left after compilation.
+// RUN: rm -rf %t/mytmp
+// RUN: mkdir -p %t/mytmp
+// RUN: env TMP=%t/mytmp %clang --target=x86_64-pc-windows-msvc -nogpulib -nogpuinc \
+// RUN: --rocm-path=%S/Inputs/rocm -no-hip-rt --offload-arch=gfx1030 -v %s 2>&1 | \
+// RUN: FileCheck -check-prefixes=CHECK %s
+// RUN: ls %t/mytmp >%t/mytmp.txt 2>&1
+// RUN: touch %t/empty.txt
+// RUN: diff %t/mytmp.txt %t/empty.txt
+
+// CHECK: -o "{{.*}}mytmp\\hip-temps-windows-gfx1030-{{.*}}.o"
+
+int main() {}
Index: clang/test/Driver/hip-temps-linux.hip
===================================================================
--- /dev/null
+++ clang/test/Driver/hip-temps-linux.hip
@@ -0,0 +1,17 @@
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: system-linux
+
+// Check no temporary files or directores are left after compilation.
+// RUN: rm -rf %t/mytmp
+// RUN: mkdir -p %t/mytmp
+// RUN: env TMPDIR=%t/mytmp %clang --target=x86_64-linux-gnu -nogpulib -nogpuinc \
+// RUN: --rocm-path=%S/Inputs/rocm -no-hip-rt --offload-arch=gfx1030 -v %s 2>&1 | \
+// RUN: FileCheck -check-prefixes=CHECK %s
+// RUN: ls %t/mytmp >%t/mytmp.txt 2>&1
+// RUN: touch %t/empty.txt
+// RUN: diff %t/mytmp.txt %t/empty.txt
+
+// CHECK: -o {{.*}}/mytmp/hip-temps-linux-gfx1030-{{.*}}.o
+
+int main() {}
Index: clang/test/Driver/hip-link-bc-to-bc.hip
===================================================================
--- clang/test/Driver/hip-link-bc-to-bc.hip
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -11,10 +11,10 @@
// RUN: 2>&1 | FileCheck -check-prefix=BITCODE %s
// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle1.bc" "-output=[[B1HOST:.*\.bc]]" "-output=[[B1DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
-// BITCODE: "{{.*}}clang{{.*}}" "-o" "[[B1DEV2:.*bundle1-gfx906.bc]]" "-x" "ir" "[[B1DEV1]]"
+// BITCODE: "{{.*}}clang{{.*}}" "-o" "[[B1DEV2:.*bundle1-gfx906-.*\.bc]]" "-x" "ir" "[[B1DEV1]]"
// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle2.bc" "-output=[[B2HOST:.*\.bc]]" "-output=[[B2DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
-// BITCODE: "{{.*}}clang{{.*}}" "-o" "[[B2DEV2:.*bundle2-gfx906.bc]]" "-x" "ir" "[[B2DEV1]]"
+// BITCODE: "{{.*}}clang{{.*}}" "-o" "[[B2DEV2:.*bundle2-gfx906-.*\.bc]]" "-x" "ir" "[[B2DEV1]]"
// BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[B1DEV2]]" "[[B2DEV2]]"
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5545,7 +5545,8 @@
const char *Driver::CreateTempFile(Compilation &C, StringRef Prefix,
StringRef Suffix, bool MultipleArchs,
- StringRef BoundArch) const {
+ StringRef BoundArch,
+ Action::OffloadKind OFK) const {
SmallString<128> TmpName;
Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
std::optional<std::string> CrashDirectory =
@@ -5565,9 +5566,19 @@
}
} else {
if (MultipleArchs && !BoundArch.empty()) {
- TmpName = GetTemporaryDirectory(Prefix);
- llvm::sys::path::append(TmpName,
- Twine(Prefix) + "-" + BoundArch + "." + Suffix);
+ llvm::Triple Triple(C.getDriver().getTargetTriple());
+ if ((OFK != Action::OFK_None && OFK != Action::OFK_Host) ||
+ !Triple.isOSDarwin()) {
+ TmpName =
+ GetTemporaryPath((Twine(Prefix) + "-" + BoundArch).str(), Suffix);
+ } else {
+ // The non-offloading toolchain on Darwin requires deterministic input
+ // file name for binaries to be deterministic.
+ TmpName = GetTemporaryDirectory(Prefix);
+ llvm::sys::path::append(TmpName,
+ Twine(Prefix) + "-" + BoundArch + "." + Suffix);
+ }
+
} else {
TmpName = GetTemporaryPath(Prefix, Suffix);
}
@@ -5683,7 +5694,8 @@
StringRef Name = llvm::sys::path::filename(BaseInput);
std::pair<StringRef, StringRef> Split = Name.split('.');
const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
- return CreateTempFile(C, Split.first, Suffix, MultipleArchs, BoundArch);
+ return CreateTempFile(C, Split.first, Suffix, MultipleArchs, BoundArch,
+ JA.getOffloadingDeviceKind());
}
SmallString<128> BasePath(BaseInput);
Index: clang/include/clang/Driver/Driver.h
===================================================================
--- clang/include/clang/Driver/Driver.h
+++ clang/include/clang/Driver/Driver.h
@@ -630,7 +630,8 @@
// Creates a temp file with $Prefix-%%%%%%.$Suffix
const char *CreateTempFile(Compilation &C, StringRef Prefix, StringRef Suffix,
bool MultipleArchs = false,
- StringRef BoundArch = {}) const;
+ StringRef BoundArch = {},
+ Action::OffloadKind OFK = Action::OFK_None) const;
/// GetNamedOutputPath - Return the name to use for the output of
/// the action \p JA. The result is appended to the compilation's
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits