Skip to content

[HIP] Suport LLVM Driver #112249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2024
Merged

[HIP] Suport LLVM Driver #112249

merged 1 commit into from
Oct 14, 2024

Conversation

petrhosek
Copy link
Member

This addresses an issue introduced in #112041.

This addresses an issue introduced in llvm#112041.
@petrhosek petrhosek requested a review from jhuber6 October 14, 2024 19:33
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Oct 14, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Petr Hosek (petrhosek)

Changes

This addresses an issue introduced in #112041.


Full diff: https://github.com/llvm/llvm-project/pull/112249.diff

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/HIPUtility.cpp (+7-6)
diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index d4d324fb339c45..9fe4f1e0e20965 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -340,6 +340,7 @@ void HIP::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
 void HIP::constructGenerateObjFileFromHIPFatBinary(
     Compilation &C, const InputInfo &Output, const InputInfoList &Inputs,
     const ArgList &Args, const JobAction &JA, const Tool &T) {
+  const Driver &D = C.getDriver();
   std::string Name = std::string(llvm::sys::path::stem(Output.getFilename()));
 
   // Create Temp Object File Generator,
@@ -347,13 +348,13 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
   // Keep them if save-temps is enabled.
   const char *ObjinFile;
   const char *BundleFile;
-  if (C.getDriver().isSaveTempsEnabled()) {
+  if (D.isSaveTempsEnabled()) {
     ObjinFile = C.getArgs().MakeArgString(Name + ".mcin");
     BundleFile = C.getArgs().MakeArgString(Name + ".hipfb");
   } else {
-    auto TmpNameMcin = C.getDriver().GetTemporaryPath(Name, "mcin");
+    auto TmpNameMcin = D.GetTemporaryPath(Name, "mcin");
     ObjinFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameMcin));
-    auto TmpNameFb = C.getDriver().GetTemporaryPath(Name, "hipfb");
+    auto TmpNameFb = D.GetTemporaryPath(Name, "hipfb");
     BundleFile = C.addTempFile(C.getArgs().MakeArgString(TmpNameFb));
   }
   HIP::constructHIPFatbinCommand(C, JA, BundleFile, Inputs, Args, T);
@@ -456,7 +457,7 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
   llvm::raw_fd_ostream Objf(ObjinFile, EC, llvm::sys::fs::OF_None);
 
   if (EC) {
-    C.getDriver().Diag(clang::diag::err_unable_to_make_temp) << EC.message();
+    D.Diag(clang::diag::err_unable_to_make_temp) << EC.message();
     return;
   }
 
@@ -466,7 +467,7 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
                        "-o",      Output.getFilename(),
                        "-x",      "assembler",
                        ObjinFile, "-c"};
-  const char *Clang = Args.MakeArgString(C.getDriver().ClangExecutable);
   C.addCommand(std::make_unique<Command>(JA, T, ResponseFileSupport::None(),
-                                         Clang, McArgs, Inputs, Output));
+                                         D.getClangProgramPath(), McArgs,
+                                         Inputs, Output, D.getPrependArg()));
 }

C.addCommand(std::make_unique<Command>(JA, T, ResponseFileSupport::None(),
Clang, McArgs, Inputs, Output));
D.getClangProgramPath(), McArgs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess we don't need to MakeArgString because the lifetime of the Driver is for the whole compilation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is what we do in other parts of the driver as well.

@jhuber6
Copy link
Contributor

jhuber6 commented Oct 14, 2024

Thanks for fixing this, didn't even know the getPrependArg was something we supported. Sorry for the extra work.

@petrhosek petrhosek merged commit 66723a0 into llvm:main Oct 14, 2024
8 of 9 checks passed
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
This addresses an issue introduced in llvm#112041.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants