ashi1 created this revision.
ashi1 added reviewers: yaxunl, kzhuravl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch allows the compile option -mcode-object-v3 to be set by default, 
unless the -mno-code-object-v3 is added to the compile options.


Repository:
  rC Clang

https://reviews.llvm.org/D57977

Files:
  lib/Driver/ToolChains/HIP.cpp


Index: lib/Driver/ToolChains/HIP.cpp
===================================================================
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -157,12 +157,20 @@
     Compilation &C, const JobAction &JA, const InputInfoList &Inputs,
     const llvm::opt::ArgList &Args, llvm::StringRef SubArchName,
     llvm::StringRef OutputFilePrefix, const char *InputFileName) const {
+
+  llvm::StringRef CodeObjectVersion;
+  // Add Code Object Version
+  if (Args.hasArg(options::OPT_mno_code_object_v3))
+    CodeObjectVersion = "-mattr=-code-object-v3";
+  else
+    CodeObjectVersion = "-mattr=+code-object-v3";
+
   // Construct llc command.
   // FIXME: -disable-promote-alloca-to-lds is a workaround for issues in
   // AMDGPUPromoteAlloca pass which cause invalid memory access in PyTorch.
   // Remove this once the issue is fixed.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-                        "-filetype=obj", "-mattr=-code-object-v3",
+                        "-filetype=obj", Args.MakeArgString(CodeObjectVersion),
                         "-disable-promote-alloca-to-lds",
                         Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
   std::string LlcOutputFileName =


Index: lib/Driver/ToolChains/HIP.cpp
===================================================================
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -157,12 +157,20 @@
     Compilation &C, const JobAction &JA, const InputInfoList &Inputs,
     const llvm::opt::ArgList &Args, llvm::StringRef SubArchName,
     llvm::StringRef OutputFilePrefix, const char *InputFileName) const {
+
+  llvm::StringRef CodeObjectVersion;
+  // Add Code Object Version
+  if (Args.hasArg(options::OPT_mno_code_object_v3))
+    CodeObjectVersion = "-mattr=-code-object-v3";
+  else
+    CodeObjectVersion = "-mattr=+code-object-v3";
+
   // Construct llc command.
   // FIXME: -disable-promote-alloca-to-lds is a workaround for issues in
   // AMDGPUPromoteAlloca pass which cause invalid memory access in PyTorch.
   // Remove this once the issue is fixed.
   ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
-                        "-filetype=obj", "-mattr=-code-object-v3",
+                        "-filetype=obj", Args.MakeArgString(CodeObjectVersion),
                         "-disable-promote-alloca-to-lds",
                         Args.MakeArgString("-mcpu=" + SubArchName), "-o"};
   std::string LlcOutputFileName =
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to