[clang] 7488dd2 - Revert "[Clang][AIX][p] Manually Claim -p in front end"

Michael Francis via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 12 00:17:36 PST 2023


Author: Michael Francis
Date: 2023-03-12T08:14:33Z
New Revision: 7488dd25e1613894d79d69f153469545b9bf660a

URL: https://github.com/llvm/llvm-project/commit/7488dd25e1613894d79d69f153469545b9bf660a
DIFF: https://github.com/llvm/llvm-project/commit/7488dd25e1613894d79d69f153469545b9bf660a.diff

LOG: Revert "[Clang][AIX][p] Manually Claim -p in front end"

This reverts commit 59848b9ebae6a92a4342b1e8aa32feaf5c9c4b51, as it
causes some failures in AIX-related Lit tests.

Added: 
    clang/test/Driver/zos-profiling-error.c

Modified: 
    clang/lib/Driver/ToolChains/AIX.cpp
    clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
    clang/test/Driver/ibm-profiling.c


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index 57234f235156e..15560e1c81bca 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,12 +164,11 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   auto getCrt0Basename = [&Args, IsArch32Bit] {
-    Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
     // Enable gprofiling when "-pg" is specified.
-    if (A->getOption().matches(options::OPT_pg))
+    if (Args.hasArg(options::OPT_pg))
       return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
     // Enable profiling when "-p" is specified.
-    else if (A->getOption().matches(options::OPT_p))
+    else if (Args.hasArg(options::OPT_p))
       return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
     else
       return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -272,7 +271,7 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
     CmdArgs.push_back("-lc");
 
-    if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
+    if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
       CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
                                            "/lib/profiled"));
       CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 87862e028636f..79fcf4526df3e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,26 +6322,20 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
             << A->getAsString(Args) << TripleStr;
     }
   }
-
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
-    if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+    if (TC.getTriple().isOSAIX()) {
+      CmdArgs.push_back("-pg");
+    } else if (!TC.getTriple().isOSOpenBSD()) {
       D.Diag(diag::err_drv_unsupported_opt_for_target)
           << A->getAsString(Args) << TripleStr;
     }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-    if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_pg)) {
+    if (TC.getTriple().isOSzOS()) {
       D.Diag(diag::err_drv_unsupported_opt_for_target)
           << A->getAsString(Args) << TripleStr;
     }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-    if (A->getOption().matches(options::OPT_p)) {
-      A->claim();
-      if (TC.getTriple().isOSAIX() && !Args.hasArgNoClaim(options::OPT_pg))
-        CmdArgs.push_back("-pg");
-    }
-  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
       (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))

diff  --git a/clang/test/Driver/ibm-profiling.c b/clang/test/Driver/ibm-profiling.c
deleted file mode 100644
index 26bc0d7784373..0000000000000
--- a/clang/test/Driver/ibm-profiling.c
+++ /dev/null
@@ -1,27 +0,0 @@
-// Check that -pg throws an error on z/OS.
-// RUN: %clang -### 2>&1 --target=s390x-none-zos -S -pg %s | FileCheck -check-prefix=FAIL-PG-NAME %s
-// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
-
-// Check that -p is still used when not linking on AIX.
-// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 -S -p -S %s \
-// RUN:   | FileCheck --check-prefix=CHECK %s
-// CHECK-NOT: warning: argument unused during compilation: '-p'
-
-// Check precedence: -pg is unused when passed first on AIX.
-// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -pg -p %s \
-// RUN:        | FileCheck --check-prefix=CHECK2 %s
-// CHECK2-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
-// CHECK2:     "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK2:     "[[SYSROOT]]/usr/lib{{/|\\\\}}mcrt0.o"
-// CHECK2:     "-L[[SYSROOT]]/lib/profiled"
-// CHECK2:     "-L[[SYSROOT]]/usr/lib/profiled"
-
-// Check precedence: -p is unused when passed first on AIX.
-// RUN: %clang -### 2>&1 --target=powerpc-ibm-aix7.1.0.0 --sysroot %S/Inputs/aix_ppc_tree -p -pg %s \
-// RUN:        | FileCheck --check-prefix=CHECK3 %s
-// CHECK3: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
-// CHECK3:     "-isysroot" "[[SYSROOT:[^"]+]]"
-// CHECK3:     "[[SYSROOT]]/usr/lib{{/|\\\\}}gcrt0.o"
-// CHECK3:     "-L[[SYSROOT]]/lib/profiled"
-// CHECK3:     "-L[[SYSROOT]]/usr/lib/profiled"
-

diff  --git a/clang/test/Driver/zos-profiling-error.c b/clang/test/Driver/zos-profiling-error.c
new file mode 100644
index 0000000000000..e969dc31a245a
--- /dev/null
+++ b/clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,2 @@
+// RUN: %clang 2>&1 -### --target=s390x-none-zos -pg -S %s | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'


        


More information about the cfe-commits mailing list