[PATCH] D117706: [openmp] Unconditionally set march commandline argument

Jon Chesterfield via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 19 11:01:29 PST 2022


JonChesterfield created this revision.
JonChesterfield added a reviewer: jhuber6.
Herald added subscribers: kerbowa, guansong, tpr, yaxunl, nhaehnle, jvesely.
JonChesterfield requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Extracted from D117246 <https://reviews.llvm.org/D117246>. This reflects the march value used by the
compile back into the toolchain arguments, letting downstream processes
such as LTO rely on it being present. Subsequent patches should also be able
to remove the two other calls to checkSystemForAMDGPU.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117706

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp


Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -285,10 +285,22 @@
 
   const OptTable &Opts = getDriver().getOpts();
 
-  if (DeviceOffloadKind != Action::OFK_OpenMP) {
-    for (Arg *A : Args) {
-      DAL->append(A);
+  if (DeviceOffloadKind == Action::OFK_OpenMP) {
+    for (Arg *A : Args)
+      if (!llvm::is_contained(*DAL, A))
+        DAL->append(A);
+
+    std::string Arch = DAL->getLastArgValue(options::OPT_march_EQ).str();
+    if (Arch.empty()) {
+      checkSystemForAMDGPU(Args, *this, Arch);
+      DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ), Arch);
     }
+
+    return DAL;
+  }
+
+  for (Arg *A : Args) {
+    DAL->append(A);
   }
 
   if (!BoundArch.empty()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117706.401341.patch
Type: text/x-patch
Size: 879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220119/a0ce444c/attachment.bin>


More information about the cfe-commits mailing list