https://github.com/saiislam created 
https://github.com/llvm/llvm-project/pull/99325

When save-temps is enabled and the given offload-archs differ
only in target features with the same arch, the intermediate
postlink.bc and postopt.bc files were getting overwritten. This
fix, suffixes the intermediate file names with the complete
TargetID.

E.g. `helloworld.amdgcn-amd-amdhsa.gfx90a:xnack+.postlink.bc`
and `helloworld.amdgcn-amd-amdhsa.gfx90a:xnack+.postopt.bc`

>From e83a9d37633dbc069ed6a0e00ed84e5a03402208 Mon Sep 17 00:00:00 2001
From: Saiyedul Islam <saiyedul.is...@amd.com>
Date: Wed, 17 Jul 2024 08:04:59 -0500
Subject: [PATCH] [ClangLinkerWrapper] Fix intermediate file naming for
 multi-arch compilation

When save-temps is enabled and the given offload-archs differ only
in target features with the same arch, the intermediate postlink.bc
and postopt.bc files were getting overwritten. This fix, suffixes
the intermediate file names with the complete TargetID.

E.g. `helloworld.amdgcn-amd-amdhsa.gfx90a:xnack+.postlink.bc`
and `helloworld.amdgcn-amd-amdhsa.gfx90a:xnack+.postopt.bc`
---
 clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index cb4cc5debae87..5edf4c982baa4 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -14,6 +14,7 @@
 //
 //===---------------------------------------------------------------------===//
 
+#include "clang/Basic/TargetID.h"
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/BinaryFormat/Magic.h"
@@ -668,7 +669,8 @@ std::unique_ptr<lto::LTO> createLTO(
     ModuleHook Hook = [](size_t, const Module &) { return true; }) {
   const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ));
   // We need to remove AMD's target-id from the processor if present.
-  StringRef Arch = Args.getLastArgValue(OPT_arch_EQ).split(":").first;
+  StringRef TargetID = Args.getLastArgValue(OPT_arch_EQ);
+  StringRef Arch = clang::getProcessorFromTargetID(Triple, TargetID);
   lto::Config Conf;
   lto::ThinBackend Backend;
   // TODO: Handle index-only thin-LTO
@@ -712,7 +714,7 @@ std::unique_ptr<lto::LTO> createLTO(
 
   if (SaveTemps) {
     std::string TempName = (sys::path::filename(ExecutableName) + "." +
-                            Triple.getTriple() + "." + Arch)
+                            Triple.getTriple() + "." + TargetID)
                                .str();
     Conf.PostInternalizeModuleHook = [=](size_t Task, const Module &M) {
       std::string File =

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to