[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-05-08 Thread Michael Francis via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5da7f30f24c4: [AIX][Clang][K] Create `-K` Option for AIX. 
(authored by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/unsupported-target-K.c


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 
'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1096,3 +1096,27 @@
 // CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-RELOCATABLE-NOT: "-l{{.*}}"
 // CHECK-RELOCATABLE-NOT: "-L{{.*}}"
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6326,6 +6326,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+  A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3421,6 +3421,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1096,3 +1096,27 @@
 // CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-RELOCATABLE-NOT: "-l{{.*}}"
 // CHECK-RELOCATABLE-NOT: "-L{{.*}}"
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck 

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-05-08 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 520502.
francii added a comment.

Remove leftover marker


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/unsupported-target-K.c


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 
'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1096,3 +1096,27 @@
 // CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-RELOCATABLE-NOT: "-l{{.*}}"
 // CHECK-RELOCATABLE-NOT: "-L{{.*}}"
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6326,6 +6326,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+  A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3421,6 +3421,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1096,3 +1096,27 @@
 // CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-RELOCATABLE-NOT: "-l{{.*}}"
 // CHECK-RELOCATABLE-NOT: "-L{{.*}}"
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// 

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-05-08 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 520455.
francii added a comment.

Don't claim `-k` when checking target


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/unsupported-target-K.c


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 
'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1096,3 +1096,28 @@
 // CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-RELOCATABLE-NOT: "-l{{.*}}"
 // CHECK-RELOCATABLE-NOT: "-L{{.*}}"
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
+>>> 8f57d6ae6c1a ([AIX][Clang][K] Create `-K` Option for AIX.)
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6326,6 +6326,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+  A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3421,6 +3421,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1096,3 +1096,28 @@
 // CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-RELOCATABLE-NOT: "-l{{.*}}"
 // CHECK-RELOCATABLE-NOT: "-L{{.*}}"
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" 

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-06 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 511431.
francii added a comment.

Add unsupported target test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/unsupported-target-K.c


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 
'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,27 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option 
'-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/unsupported-target-K.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-target-K.c
@@ -0,0 +1,8 @@
+// Check powerpc64-unknown-linux-gnu. -K not supported.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc64-unknown-linux-gnu \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-SUPPORT %s
+// CHECK-K-SUPPORT: clang: error: unsupported option '-K' for target 'powerpc64-unknown-linux-gnu'
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,27 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// 

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-05 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 511208.
francii added a comment.

Add -c test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,27 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option 
'-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused 
[-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,27 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
+
+// Check powerpc-ibm-aix7.1.0.0. -K unused when not linking.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:-c \
+// RUN:   | FileCheck --check-prefixes=CHECK-K-UNUSED %s
+// CHECK-K-UNUSED: clang: warning: -K: 'linker' input unused [-Wunused-command-line-argument]
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-04 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D146399#4243803 , 
@hubert.reinterpretcast wrote:

> @francii, what happens when `-K` is used on a pure-compile (`-c`) invocation? 
> Do we get an "unused" message? Should we be testing that?
> I think we should be testing the diagnostic for the "wrong target" usage as 
> well?

When compiling with `-c`, we will get the "unused" message. I will include a 
test case for it.

Do we need a test case for the diagnostic? If we are only supporting one 
target, which triple would be used for the test?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

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


[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-03-27 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 508709.
francii added a comment.

Remove `NoArgumentUnused`, claim -K when checking target.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,17 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option 
'-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,17 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
"Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146578: [AIX][r] Do not call AddFilePathLibArgs with -r

2023-03-21 Thread Michael Francis via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dc04557d71c: [AIX][r] Do not call AddFilePathLibArgs with 
-r (authored by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146578/new/

https://reviews.llvm.org/D146578

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -234,8 +234,8 @@
 
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_r)) {
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 if (getToolChain().ShouldLinkCXXStdlib(Args))


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -234,8 +234,8 @@
 
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_r)) {
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 if (getToolChain().ShouldLinkCXXStdlib(Args))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146578: [AIX][r] Do not call AddFilePathLibArgs with -r

2023-03-21 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

We do not want to add file path lib args when -r is specified.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146578

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -234,8 +234,8 @@
 
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_r)) {
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 if (getToolChain().ShouldLinkCXXStdlib(Args))


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -234,8 +234,8 @@
 
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   if (!Args.hasArg(options::OPT_r)) {
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
 ToolChain.addProfileRTLibs(Args, CmdArgs);
 
 if (getToolChain().ShouldLinkCXXStdlib(Args))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146443: [AIX] Consolidate Crt0Basename logic

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c483a046d2f: [AIX] Consolidate Crt0Basename logic (authored 
by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146443/new/

https://reviews.llvm.org/D146443

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -163,19 +163,19 @@
 CmdArgs.push_back("-bpD:0x11000");
   }
 
-  auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-  // Enable gprofiling when "-pg" is specified.
-  if (A->getOption().matches(options::OPT_pg))
-return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-  // Enable profiling when "-p" is specified.
-  return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-}
-return IsArch32Bit ? "crt0.o" : "crt0_64.o";
-  };
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_shared, options::OPT_r)) {
+auto getCrt0Basename = [, IsArch32Bit] {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+// Enable gprofiling when "-pg" is specified.
+if (A->getOption().matches(options::OPT_pg))
+  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+// Enable profiling when "-p" is specified.
+return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
+  }
+  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+};
+
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -163,19 +163,19 @@
 CmdArgs.push_back("-bpD:0x11000");
   }
 
-  auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-  // Enable gprofiling when "-pg" is specified.
-  if (A->getOption().matches(options::OPT_pg))
-return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-  // Enable profiling when "-p" is specified.
-  return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-}
-return IsArch32Bit ? "crt0.o" : "crt0_64.o";
-  };
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_shared, options::OPT_r)) {
+auto getCrt0Basename = [, IsArch32Bit] {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+// Enable gprofiling when "-pg" is specified.
+if (A->getOption().matches(options::OPT_pg))
+  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+// Enable profiling when "-p" is specified.
+return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
+  }
+  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+};
+
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137372: [Test][[AIX][pg] Add 32-bit linker invocation tests

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii closed this revision.
francii added a comment.

Closing as this revision has landed

https://reviews.llvm.org/rGe07a7040d9c6dbdd71e55d1153bfe1357079e511


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137372/new/

https://reviews.llvm.org/D137372

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


[PATCH] D137373: [Test][[AIX][p] Add 64-bit linker invocation tests

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii closed this revision.
francii added a comment.

Closing as this revision has landed

https://reviews.llvm.org/rGdc9846ce988b9ddfcbc42cd462d5d94b634b3161


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137373/new/

https://reviews.llvm.org/D137373

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


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii closed this revision.
francii added a comment.

Closing as this revision has landed
https://reviews.llvm.org/rG0fae851824bc1b64a727aeb331b7a0787599bd1f


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

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


[PATCH] D146443: [AIX] Consolidate Crt0Basename logic

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506684.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146443/new/

https://reviews.llvm.org/D146443

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -163,19 +163,19 @@
 CmdArgs.push_back("-bpD:0x11000");
   }
 
-  auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-  // Enable gprofiling when "-pg" is specified.
-  if (A->getOption().matches(options::OPT_pg))
-return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-  // Enable profiling when "-p" is specified.
-  return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-}
-return IsArch32Bit ? "crt0.o" : "crt0_64.o";
-  };
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_shared, options::OPT_r)) {
+auto getCrt0Basename = [, IsArch32Bit] {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+// Enable gprofiling when "-pg" is specified.
+if (A->getOption().matches(options::OPT_pg))
+  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+// Enable profiling when "-p" is specified.
+return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
+  }
+  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+};
+
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -163,19 +163,19 @@
 CmdArgs.push_back("-bpD:0x11000");
   }
 
-  auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-  // Enable gprofiling when "-pg" is specified.
-  if (A->getOption().matches(options::OPT_pg))
-return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-  // Enable profiling when "-p" is specified.
-  return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-}
-return IsArch32Bit ? "crt0.o" : "crt0_64.o";
-  };
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_shared, options::OPT_r)) {
+auto getCrt0Basename = [, IsArch32Bit] {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+// Enable gprofiling when "-pg" is specified.
+if (A->getOption().matches(options::OPT_pg))
+  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+// Enable profiling when "-p" is specified.
+return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
+  }
+  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+};
+
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146443: [AIX] Consolidate Crt0Basename logic

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

when certain flags are specified, the Crt0 object files are not linked.
However, the logic for determining which files will always run. This
patch moves that logic so that the basename is only determined if it is
needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146443

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -163,19 +163,19 @@
 CmdArgs.push_back("-bpD:0x11000");
   }
 
-  auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-  // Enable gprofiling when "-pg" is specified.
-  if (A->getOption().matches(options::OPT_pg))
-return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-  // Enable profiling when "-p" is specified.
-  return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-}
-return IsArch32Bit ? "crt0.o" : "crt0_64.o";
-  };
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_shared, options::OPT_r)) {
+auto getCrt0Basename = [, IsArch32Bit] {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+// Enable gprofiling when "-pg" is specified.
+if (A->getOption().matches(options::OPT_pg))
+  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+// Enable profiling when "-p" is specified.
+return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
+  }
+  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+};
+
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -163,19 +163,19 @@
 CmdArgs.push_back("-bpD:0x11000");
   }
 
-  auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
-  // Enable gprofiling when "-pg" is specified.
-  if (A->getOption().matches(options::OPT_pg))
-return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-  // Enable profiling when "-p" is specified.
-  return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-}
-return IsArch32Bit ? "crt0.o" : "crt0_64.o";
-  };
-
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_shared, options::OPT_r)) {
+auto getCrt0Basename = [, IsArch32Bit] {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+// Enable gprofiling when "-pg" is specified.
+if (A->getOption().matches(options::OPT_pg))
+  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+// Enable profiling when "-p" is specified.
+return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
+  }
+  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+};
+
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5259da75b935: [AIX][Clang] Respect -r when invoking the 
linker (authored by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,22 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-L/foo/bar \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "{{.*}}ld{{(.exe)?}}"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE: "-L/foo/bar"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
+// CHECK-RELOCATABLE-NOT: "-L{{.*}}"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -235,47 +235,49 @@
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 
-if (D.CCCIsCXX())
-  CmdArgs.push_back("-lm");
+  if (D.CCCIsCXX())
+CmdArgs.push_back("-lm");
 
-CmdArgs.push_back("-lc");
+  CmdArgs.push_back("-lc");
 
-if (Args.hasArgNoClaim(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) +
-   "/usr/lib/profiled"));
+  if 

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506580.
francii added a comment.

Clean up test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,17 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option 
'-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+  A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,17 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+  A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
"Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506577.
francii added a comment.

Update test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,22 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-L/foo/bar \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "{{.*}}ld{{(.exe)?}}"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE: "-L/foo/bar"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
+// CHECK-RELOCATABLE-NOT: "-L{{.*}}"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -235,47 +235,49 @@
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 
-if (D.CCCIsCXX())
-  CmdArgs.push_back("-lm");
+  if (D.CCCIsCXX())
+CmdArgs.push_back("-lm");
 
-CmdArgs.push_back("-lc");
+  CmdArgs.push_back("-lc");
 
-if (Args.hasArgNoClaim(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) +
-   "/usr/lib/profiled"));
+  if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
+

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-03-20 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506575.
francii added a comment.

Add test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,19 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option 
'-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "-b32"
+// CHECK-K: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"`
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+  A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,19 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -K is a passthrough linker option.
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-K \
+// RUN:   | FileCheck --check-prefixes=CHECK-K %s
+// CHECK-K: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-K: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-K: "{{.*}}ld{{(.exe)?}}"
+// CHECK-K: "-b32"
+// CHECK-K: "-bpT:0x1000" "-bpD:0x2000"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-K: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-K: "-K"`
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,11 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K);
+  A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
"Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-03-19 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506447.
francii added a comment.

nit: spacing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && 
!TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
"Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput, NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-03-19 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

`-K` is a linker option on AIX, that is used to align the header, text, data, 
and loader sections of the output file so
that each section begins on a page boundary.

This patch creates the `-K` option in clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146399

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && 
!TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
"Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput,NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6328,6 +6328,10 @@
 }
   }
 
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_K); A && !TC.getTriple().isOSAIX())
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << A->getAsString(Args) << TripleStr;
+
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
 CmdArgs.push_back("-fapple-kext");
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3405,6 +3405,7 @@
   HelpText<"Overlay the virtual filesystem described by file over the real file system. "
"Additionally, pass this overlay file to the linker if it supports it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
+def K : Flag<["-"], "K">, Flags<[LinkerInput,NoArgumentUnused]>;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,
 Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-19 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 506439.
francii added a comment.

Allow user-specified -L and -l options


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -235,47 +235,49 @@
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 
-if (D.CCCIsCXX())
-  CmdArgs.push_back("-lm");
+  if (D.CCCIsCXX())
+CmdArgs.push_back("-lm");
 
-CmdArgs.push_back("-lc");
+  CmdArgs.push_back("-lc");
 
-if (Args.hasArgNoClaim(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) +
-   "/usr/lib/profiled"));
+  if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505691.
francii added a comment.

Add missing bracket


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,50 +232,52 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505689.
francii added a comment.

Add missing bracket


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,56 +232,58 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+CmdArgs.push_back("-lpthreads");
 

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505657.
francii added a comment.
Herald added a subscriber: jplehr.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,57 +232,58 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac1d143b0ef9: [Clang][AIX][p] Manually Claim -p in front end 
(authored by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if 

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505653.
francii added a comment.

Rebase for push


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, 

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505602.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505601.
francii added a comment.

Don't claim when checking for object file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,7 +164,7 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg)) {
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
   // Enable gprofiling when "-pg" is specified.
   if (A->getOption().matches(options::OPT_pg))
 return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,7 +164,7 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg)) {
+if (Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg)) {
   // Enable gprofiling when "-pg" is specified.
   if (A->getOption().matches(options::OPT_pg))
 return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-15 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505560.
francii added a comment.

Fix segfault


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,14 +164,14 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
-  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
-// Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg)) {
+  // Enable gprofiling when "-pg" is specified.
+  if (A->getOption().matches(options::OPT_pg))
+return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
+  // Enable profiling when "-p" is specified.
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
-  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
+}
+return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505243.
francii added a comment.

Wildcard check for `-l`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,18 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-l{{.*}}"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1703,6 +1703,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,50 +232,52 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if "-pthreads" or "-pthread" is present.
+  if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
+

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505221.
francii added a comment.

Update test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,22 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-lc++"
+// CHECK-RELOCATABLE-NOT: "-lc++abi"
+// CHECK-RELOCATABLE-NOT: "-lunwind"
+// CHECK-RELOCATABLE-NOT: "-lm"
+// CHECK-RELOCATABLE-NOT: "-lc"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1703,6 +1703,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,50 +232,52 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
   }
-}
 
-// Support POSIX threads if "-pthreads" or "-pthread" is present.
-if (Args.hasArg(options::OPT_pthreads, options::OPT_pthread))
-  CmdArgs.push_back("-lpthreads");
+  // Support POSIX threads if 

[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505186.
francii added a comment.

Make `-p` a CC1 option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +

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

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 505179.
francii added a comment.

Update message


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146073/new/

https://reviews.llvm.org/D146073

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
  

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

2023-03-14 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This reverts commit 7488dd25e1613894d79d69f153469545b9bf660a 
. The
original revert was due to the original commit causing segfaults.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146073

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if 

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 504884.
francii added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, ormris.

Update check in AIX.cpp, add test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -1077,3 +1077,24 @@
 // RUN:-fopenmp=libfoo \
 // RUN:   | FileCheck --check-prefixes=CHECK-FOPENMP-FOO %s
 // CHECK-FOPENMP-FOO: error: unsupported argument 'libfoo' to option '-fopenmp='
+
+// Check powerpc-ibm-aix7.1.0.0. -r does not link object files or libraries
+// RUN: %clang %s 2>&1 -### \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:--unwindlib=libunwind \
+// RUN:-r \
+// RUN:   | FileCheck --check-prefixes=CHECK-RELOCATABLE %s
+
+// CHECK-RELOCATABLE: "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-RELOCATABLE: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-RELOCATABLE: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-RELOCATABLE-NOT: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
+// CHECK-RELOCATABLE-NOT: "-lc++"
+// CHECK-RELOCATABLE-NOT: "-lc++abi"
+// CHECK-RELOCATABLE-NOT: "-lunwind"
+// CHECK-RELOCATABLE-NOT: "-lm"
+// CHECK-RELOCATABLE-NOT: "-lc"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,50 +232,52 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
-  // Add directory to library search path.
-  Args.AddAllArgs(CmdArgs, options::OPT_L);
-  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
-  if (getToolChain().ShouldLinkCXXStdlib(Args))
-getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
-
-// Add OpenMP runtime if -fopenmp is specified.
-if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
- options::OPT_fno_openmp, false)) {
-  switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
-  case Driver::OMPRT_OMP:
-CmdArgs.push_back("-lomp");
-break;
-  case Driver::OMPRT_IOMP5:
-CmdArgs.push_back("-liomp5");
-break;
-  case Driver::OMPRT_GOMP:
-CmdArgs.push_back("-lgomp");
-break;
-  case Driver::OMPRT_Unknown:
-// Already diagnosed.
-break;
+  if (!Args.hasArg(options::OPT_r)) {
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+ToolChain.addProfileRTLibs(Args, CmdArgs);
+
+if (getToolChain().ShouldLinkCXXStdlib(Args))
+  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+
+if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+
+  // Add OpenMP runtime if -fopenmp is specified.
+  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
+   options::OPT_fno_openmp, false)) {
+switch (ToolChain.getDriver().getOpenMPRuntime(Args)) {
+case Driver::OMPRT_OMP:
+  CmdArgs.push_back("-lomp");
+  break;
+case Driver::OMPRT_IOMP5:
+  CmdArgs.push_back("-liomp5");
+  break;
+case Driver::OMPRT_GOMP:
+  CmdArgs.push_back("-lgomp");
+  break;
+case Driver::OMPRT_Unknown:
+  // Already diagnosed.
+  break;
+}
  

[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-13 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D145899#4190055 , @w2yehia wrote:

> testcase?

This patch is still WIP while I verify the libraries that we intend not to add. 
But I will add a test case once I've done so :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

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


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 504518.
francii added a comment.

Move `-r` check in `CommonArgs.cpp`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,6 +232,13 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
+  if (Args.hasArg(options::OPT_r)) {
+const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, 
Output));
+return;
+  }
+
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1693,6 +1693,8 @@
   }
   case ToolChain::UNW_CompilerRT:
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
   if (LGT != LibGccType::StaticLibGcc)
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,6 +232,13 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
+  if (Args.hasArg(options::OPT_r)) {
+const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, Output));
+return;
+  }
+
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 504516.
francii added a comment.

Move comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145899/new/

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1692,6 +1692,8 @@
 break;
   }
   case ToolChain::UNW_CompilerRT:
+if (Args.hasArg(options::OPT_r))
+  break;
 if (TC.getTriple().isOSAIX()) {
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,6 +232,13 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
+  if (Args.hasArg(options::OPT_r)) {
+const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, 
Output));
+return;
+  }
+
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1692,6 +1692,8 @@
 break;
   }
   case ToolChain::UNW_CompilerRT:
+if (Args.hasArg(options::OPT_r))
+  break;
 if (TC.getTriple().isOSAIX()) {
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -232,6 +232,13 @@
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-bE:") + ExportList));
   }
 
+  if (Args.hasArg(options::OPT_r)) {
+const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, Output));
+return;
+  }
+
   // Add directory to library search path.
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker On AIX, libraries are still being linked when `-r` is passed to the driver. This patch corrects this error.

2023-03-13 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145899

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1692,6 +1692,8 @@
 break;
   }
   case ToolChain::UNW_CompilerRT:
+if (Args.hasArg(options::OPT_r))
+  break;
 if (TC.getTriple().isOSAIX()) {
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -233,6 +233,13 @@
   }
 
   // Add directory to library search path.
+  if (Args.hasArg(options::OPT_r)) {
+const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, 
Output));
+return;
+  }
+
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   ToolChain.addProfileRTLibs(Args, CmdArgs);


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1692,6 +1692,8 @@
 break;
   }
   case ToolChain::UNW_CompilerRT:
+if (Args.hasArg(options::OPT_r))
+  break;
 if (TC.getTriple().isOSAIX()) {
   // AIX only has libunwind as a shared library. So do not pass
   // anything in if -static is specified.
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -175,7 +175,7 @@
   };
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
-   options::OPT_shared)) {
+   options::OPT_shared, options::OPT_r)) {
 CmdArgs.push_back(
 Args.MakeArgString(ToolChain.GetFilePath(getCrt0Basename(;
 
@@ -233,6 +233,13 @@
   }
 
   // Add directory to library search path.
+  if (Args.hasArg(options::OPT_r)) {
+const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+C.addCommand(std::make_unique(
+JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, Inputs, Output));
+return;
+  }
+
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   ToolChain.AddFilePathLibArgs(Args, CmdArgs);
   ToolChain.addProfileRTLibs(Args, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Manually claim -p in front end

2023-03-11 Thread Michael Francis via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG59848b9ebae6: [Clang][AIX][p] Manually Claim -p in front end 
(authored by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-07 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 503109.
francii added a comment.

Test case nit


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-07 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 503107.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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=CHECK3 %s
+// CHECK3-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=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK: "-L[[SYSROOT]]/lib/profiled"
+// CHECK: "-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=CHECK2 %s
+// CHECK2: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-06 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 502693.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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=CHECK3 %s
+// CHECK3-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=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK: "-L[[SYSROOT]]/lib/profiled"
+// CHECK: "-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=CHECK2 %s
+// CHECK2: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-03 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 502204.
francii added a comment.

Fix missing bracket


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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=CHECK3 %s
+// CHECK3-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=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK: "-L[[SYSROOT]]/lib/profiled"
+// CHECK: "-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=CHECK2 %s
+// CHECK2: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6322,20 +6322,26 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (TC.getTriple().isOSAIX()) {
-  CmdArgs.push_back("-pg");
-} else if (!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_pg)) {
-if (TC.getTriple().isOSzOS()) {
+  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
   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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-03 Thread Michael Francis via Phabricator via cfe-commits
francii added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6327
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {

daltenty wrote:
> Actually, a question here. Does this now result in the arg being claimed even 
> if nothing was done it? Since there are case we don't go into the error path.
I've updated the logic of this patch entirely. With these changes, using `-p` 
and `-pg` together now gives precedence to the option that is passed last.

Now, whenever we check for `-p`, we **never** do a blind claim. We instead 
manually claim `-p` in the following instances:
1. The user passes `-p` without also passing `-pg`: We manually claim `-p`, and 
push `-pg` to `CmdArgs`.
2. The user passes both `-p` and `-pg`, but `-p` is given precedence: We 
manually claim `-p`, and do nothing (since `-pg` is already in `CmdArgs`).

As a result, `-p` will only warn that it goes unused if it is passed before 
`-pg` (i.e. `clang -p -pg`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

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


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-02 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 502006.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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=CHECK3 %s
+// CHECK3-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=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK: "-L[[SYSROOT]]/lib/profiled"
+// CHECK: "-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=CHECK2 %s
+// CHECK2: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6321,21 +6321,26 @@
 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()) {
-  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_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_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)) {
+  if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
+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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-02 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501929.
francii added a comment.

Update based on review


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,27 @@
+// 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=CHECK3 %s
+// CHECK3-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=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK: "-L[[SYSROOT]]/lib/profiled"
+// CHECK: "-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=CHECK2 %s
+// CHECK2: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6323,21 +6323,26 @@
 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()) {
-  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_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_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)) {
+  if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
+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)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501711.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,44 @@
+// RUN: %clang -### 2>&1 \
+// RUN:--target=s390x-none-zos \
+// RUN:-S \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check precedence: -pg is unused when passed first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:-pg \
+// RUN:-p \
+// RUN:%s \
+// RUN:| FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK: "-L[[SYSROOT]]/lib/profiled"
+// CHECK: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first.
+// RUN: %clang -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:-p \
+// RUN:-pg \
+// RUN:%s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-S \
+// RUN:%s \
+// RUN:   | FileCheck --check-prefix=CHECK3 %s
+// CHECK3-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6323,21 +6323,28 @@
 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()) {
-  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_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_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)) {
+  if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
+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()) {
+  if (!Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 }
-  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // 

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501698.
francii added a comment.

Add more test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,44 @@
+// RUN: %clang -### 2>&1 \
+// RUN:--target=s390x-none-zos \
+// RUN:-S \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check precedence: -pg is unused when passed first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:-pg \
+// RUN:-p \
+// RUN:%s \
+// RUN:| FileCheck --check-prefix=CHECK %s
+// CHECK-NOT: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK: "[[SYSROOT]]/usr/lib{{/|}}mcrt0.o"
+// CHECK: "-L[[SYSROOT]]/lib/profiled"
+// CHECK: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check precedence: -p is unused when passed first.
+// RUN: %clang -### \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:--sysroot %S/Inputs/aix_ppc_tree \
+// RUN:-p \
+// RUN:-pg \
+// RUN:%s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK2 %s
+// CHECK2: warning: argument unused during compilation: '-p' [-Wunused-command-line-argument]
+// CHECK2: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK2: "[[SYSROOT]]/usr/lib{{/|}}gcrt0.o"
+// CHECK2: "-L[[SYSROOT]]/lib/profiled"
+// CHECK2: "-L[[SYSROOT]]/usr/lib/profiled"
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-S \
+// RUN:%s \
+// RUN:   | FileCheck --check-prefix=CHECK3 %s
+// CHECK3-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6323,21 +6323,28 @@
 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()) {
-  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_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_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)) {
+  if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
+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()) {
+  if (!Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 }
-  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : 

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501692.
francii added a comment.

Always throw error when `-p` is in command.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,34 @@
+// RUN: %clang -### 2>&1 \
+// RUN:--target=s390x-none-zos \
+// RUN:		   -S \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check precedence: -pg is unused when passed first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-pg \
+// RUN:-p \
+// RUN:%s \
+// RUN:   	   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
+// Check precedence: -p is unused when past first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck --check-prefix=UNUSED %s
+// UNUSED: warning: argument unused during compilation: '-p'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-S \
+// RUN:%s \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6323,21 +6323,28 @@
 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()) {
-  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_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_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)) {
+  if (!(TC.getTriple().isOSAIX() || TC.getTriple().isOSOpenBSD())) {
+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()) {
+  if (!Args.hasArgNoClaim(options::OPT_pg))
+CmdArgs.push_back("-pg");
+}
+  }
 }
-  }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
   

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501668.
francii added a comment.

Cleanup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,34 @@
+// RUN: %clang -### 2>&1 \
+// RUN:--target=s390x-none-zos \
+// RUN:		   -S \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check presecedence: -pg is unused when passed first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-pg \
+// RUN:-p \
+// RUN:%s \
+// RUN:   	   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
+// Check presecedence: -p is unused when past first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck --check-prefix=UNUSED %s
+// UNUSED: warning: argument unused during compilation: '-p'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-S \
+// RUN:%s \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,18 +6324,21 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  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_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_pg)) {
+  if (TC.getTriple().isOSzOS()) {
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+  }
+} else if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX()) {
+if (!Args.hasArgNoClaim(options::OPT_pg))
+  CmdArgs.push_back("-pg");
+  } else if (!TC.getTriple().isOSOpenBSD()) {
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+  }
 }
   }
 
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,11 +164,12 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
 // Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+if (A->getOption().matches(options::OPT_pg))
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p))
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
 else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
@@ -271,7 +272,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(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) +
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501666.
francii added a comment.

Update to claiming logic:
if `-pg` is passed, only claim `-p` if `-p` is passed afterwards.
Otherwise, always claim `-p`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c

Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,34 @@
+// RUN: %clang -### 2>&1 \
+// RUN:--target=s390x-none-zos \
+// RUN:		   -S \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
+
+// Check presecedence: -pg is unused when passed first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-pg \
+// RUN:-p \
+// RUN:%s \
+// RUN:   	   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
+// Check presecedence: -p is unused when past first.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-pg \
+// RUN:%s \
+// RUN:| FileCheck --check-prefix=UNUSED %s
+// UNUSED: warning: argument unused during compilation: '-p'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang -### 2>&1 \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:-p \
+// RUN:-S \
+// RUN:%s \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,18 +6324,23 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  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_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_pg)) {
+  if (TC.getTriple().isOSzOS()) {
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+  }
+} else if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
+  if (TC.getTriple().isOSAIX()) {
+if (!Args.hasArgNoClaim(options::OPT_pg)) {
+  A->claim();
+  CmdArgs.push_back("-pg");
+}
+  } else if (!TC.getTriple().isOSOpenBSD()) {
+D.Diag(diag::err_drv_unsupported_opt_for_target)
+<< A->getAsString(Args) << TripleStr;
+  }
 }
   }
 
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -164,13 +164,15 @@
   }
 
   auto getCrt0Basename = [, IsArch32Bit] {
-// Enable gprofiling when "-pg" is specified.
-if (Args.hasArg(options::OPT_pg))
+Arg *A = Args.getLastArgNoClaim(options::OPT_p, options::OPT_pg);
+if (A->getOption().matches(options::OPT_pg))
+  // Enable gprofiling when "-pg" is specified.
   return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
 // Enable profiling when "-p" is specified.
-else if (Args.hasArg(options::OPT_p))
+else if (A->getOption().matches(options::OPT_p)) {
+  A->claim();
   return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
-else
+} else
   return IsArch32Bit ? "crt0.o" : "crt0_64.o";
   };
 
@@ -271,7 +273,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+if (Args.hasArgNoClaim(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501533.
francii added a comment.

nit


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,11 @@
+// Check that -pg is disabled on z/OS.
+// 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'
+
+// Check that -p does not claim to be unused when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,11 @@
+// Check that -pg is disabled on z/OS.
+// 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'
+
+// Check that -p does not claim to be unused when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501531.
francii added a comment.

Add test case descriptions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,11 @@
+// Check that g-profiling is disabled on z/OS.
+// 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'
+
+// Check that -p does not claim to be unused when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,11 @@
+// Check that g-profiling is disabled on z/OS.
+// 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'
+
+// Check that -p does not claim to be unused when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501530.
francii added a comment.

Remove old test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,10 @@
+// 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'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,10 @@
+// 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'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501529.
francii added a comment.

Remove old test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/unused.c
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/unused.c
===
--- /dev/null
+++ clang/test/Driver/unused.c
@@ -0,0 +1,8 @@
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,10 @@
+// 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'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/unused.c
===
--- /dev/null
+++ clang/test/Driver/unused.c
@@ -0,0 +1,8 @@
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,10 @@
+// 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'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501527.
francii added a comment.

Merge z/OS and AIX profiling tests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/ibm-profiling.c
  clang/test/Driver/unused.c
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/unused.c
===
--- /dev/null
+++ clang/test/Driver/unused.c
@@ -0,0 +1,8 @@
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,10 @@
+// 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'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/test/Driver/zos-profiling-error.c
===
--- clang/test/Driver/zos-profiling-error.c
+++ /dev/null
@@ -1,2 +0,0 @@
-// 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'
Index: clang/test/Driver/unused.c
===
--- /dev/null
+++ clang/test/Driver/unused.c
@@ -0,0 +1,8 @@
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
Index: clang/test/Driver/ibm-profiling.c
===
--- /dev/null
+++ clang/test/Driver/ibm-profiling.c
@@ -0,0 +1,10 @@
+// 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'
+
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-03-01 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501526.
francii added a comment.

Add test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unused.c


Index: clang/test/Driver/unused.c
===
--- /dev/null
+++ clang/test/Driver/unused.c
@@ -0,0 +1,8 @@
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/test/Driver/unused.c
===
--- /dev/null
+++ clang/test/Driver/unused.c
@@ -0,0 +1,8 @@
+// Check that -p is still used when not linking on AIX.
+// RUN: %clang %s -### 2>&1 \
+// RUN:-p \
+// RUN:-S \
+// RUN:--target=powerpc-ibm-aix7.1.0.0 \
+// RUN:   | FileCheck --check-prefix=UNUSED %s
+// UNUSED-NOT: warning: argument unused during compilation: '-p'
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-02-28 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 501362.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145021/new/

https://reviews.llvm.org/D145021

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


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145021: [Clang][AIX][p] Claim -p in front end

2023-02-28 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

The current implementation of `-p` does not claim the argument once it
is passed. Since it pushes `-pg` directly, it is only ever referred to again 
when linking. As a result, when compiling with `-S`, the compiler warns that 
`-p` goes unused even though that is not the case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145021

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


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6324,7 +6324,7 @@
 << A->getAsString(Args) << TripleStr;
 }
   }
-  if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
+  if (Arg *A = Args.getLastArg(options::OPT_p)) {
 if (TC.getTriple().isOSAIX()) {
   CmdArgs.push_back("-pg");
 } else if (!TC.getTriple().isOSOpenBSD()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137756: [z/OS][pg] Throw error when using -pg on z/OS

2023-02-09 Thread Michael Francis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGec094d259ecf: [z/OS][pg] Throw error when using -pg on z/OS 
(authored by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ 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'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6338,6 +6338,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ 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'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6338,6 +6338,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-02-09 Thread Michael Francis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f85c560b43b: [Clang][AIX][p]Enable -p Functionality 
(authored by francii).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6331,7 +6331,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+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;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4179,6 +4179,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4225,7 +4226,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6331,7 +6331,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+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;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ 

[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-02-07 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 495588.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6331,7 +6331,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+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;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4175,6 +4175,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4221,7 +4222,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6331,7 +6331,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+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;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_pg)) 

[PATCH] D137756: [z/OS][pg] Throw error when using -pg on z/OS

2023-02-07 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 495570.
francii added a comment.

Update test case verbosity


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ 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'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6336,6 +6336,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ 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'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6336,6 +6336,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137756: [z/OS][pg] Throw error when using -pg on z/OS

2023-02-06 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 495267.
francii added a comment.

Rebase and test case update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,2 @@
+// RUN: not %clang --target=s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6336,6 +6336,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,2 @@
+// RUN: not %clang --target=s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6336,6 +6336,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137756: [z/OS][pg] Throw error when using -pg on z/OS

2023-01-30 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 493401.
francii added a comment.

Move check to Clang.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,4 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6289,6 +6289,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,4 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6289,6 +6289,12 @@
   << A->getAsString(Args) << TripleStr;
 }
   }
+  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 (Args.getLastArg(options::OPT_fapple_kext) ||
   (Args.hasArg(options::OPT_mkernel) && types::isCXX(InputType)))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-28 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 493054.
francii added a comment.

Update based on review


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6284,7 +6284,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+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;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4138,6 +4138,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4184,7 +4185,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6284,7 +6284,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+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;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if 

[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-25 Thread Michael Francis via Phabricator via cfe-commits
francii added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:274
 
-if (Args.hasArg(options::OPT_pg)) {
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +

daltenty wrote:
> Maybe I'm a bit confused, I though these options had different handling with 
> respect to the paths? Otherwise, it's simply an alias.
You may be referring to lines 167-175 of this same file:
```
  auto getCrt0Basename = [, IsArch32Bit] {
// Enable gprofiling when "-pg" is specified.
if (Args.hasArg(options::OPT_pg))
  return IsArch32Bit ? "gcrt0.o" : "gcrt0_64.o";
// Enable profiling when "-p" is specified.
else if (Args.hasArg(options::OPT_p))
  return IsArch32Bit ? "mcrt0.o" : "mcrt0_64.o";
else
  return IsArch32Bit ? "crt0.o" : "crt0_64.o";
  };
```
This is the only time we handle `-p` differently. With both `-p` and `-pg`, we 
want to link the profiled libraries.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

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


[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-25 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 492189.
francii added a comment.

Remove cc1 option


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6288,6 +6288,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4138,6 +4138,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4184,7 +4185,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6288,6 +6288,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_pg)) {
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-23 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 491444.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6288,6 +6288,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4138,6 +4138,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">, 
Flags<[CC1Option]>;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4184,7 +4185,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6288,6 +6288,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_pg)) {
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-22 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 491204.
francii added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6288,6 +6288,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4137,6 +4137,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">, 
Flags<[CC1Option]>;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4183,7 +4184,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6288,6 +6288,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_pg)) {
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-19 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 490638.
francii added a comment.

Specifically check for AIX before pushing pg


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6260,6 +6260,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -252,7 +252,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">, 
Flags<[CC1Option]>;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4182,7 +4183,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6260,6 +6260,8 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+if (TC.getTriple().isOSAIX())
+  CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -252,7 +252,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_pg)) {
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   

[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-18 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 490261.
francii added a comment.

Remove codegen option approach


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6260,6 +6260,7 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -252,7 +252,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4136,6 +4136,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">, 
Flags<[CC1Option]>;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4182,7 +4183,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6260,6 +6260,7 @@
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
+CmdArgs.push_back("-pg");
   }
 
   if (Args.getLastArg(options::OPT_fapple_kext) ||
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -252,7 +252,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: 

[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-10 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 487907.
francii added a comment.

Add supports profiling check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -430,7 +430,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6223,6 +6224,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7338,7 +7340,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -252,7 +252,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(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) +
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1050,7 +1050,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -952,7 +952,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
 CodeGenOpts.InstrumentFunctionEntryBare ||
 CodeGenOpts.InstrumentFunctionsAfterInlining ||
-CodeGenOpts.InstrumentForProfiling) {
+CodeGenOpts.InstrumentForProfiling ||
+CodeGenOpts.InstrumentForProfilingGraph) {
   PB.registerPipelineStartEPCallback(
   [](ModulePassManager , OptimizationLevel Level) {
 MPM.addPass(createModuleToFunctionPassAdaptor(
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4129,8 +4129,10 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, MarshallingInfoFlag>;
-def pg : Flag<["-"], "pg">, 

[PATCH] D137756: [z/OS][pg] Throw error when using -pg on z/OS

2023-01-04 Thread Michael Francis via Phabricator via cfe-commits
francii added inline comments.



Comment at: clang/lib/Driver/ToolChains/ZOS.cpp:22
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);

@MaskRay we still need `-pg` to error-out on z/OS. Should the check for this be 
moved to `clang/lib/Driver/ToolChains/Clang.cpp` instead?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

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


[PATCH] D137756: [z/OS][pg] Throw error when using -pg on z/OS

2023-01-04 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D137756#4023531 , 
@hubert.reinterpretcast wrote:

> In D137756#4018666 , @MaskRay wrote:
>
>> Most targets reject `-p` now. It's unnecessary to have another z/OS specific 
>> diagnostic. So this patch can be abandoned.
>>
>>   % fclang -p a.cc
>>   clang-16: error: unsupported option '-p' for target 
>> 'x86_64-unknown-linux-gnu'
>
> @francii, if you can confirm:
>
> 1. that there is a test that covers that error for z/OS, and
> 2. any comments in the code associated with generating the error above do not 
> misrepresent the rationale for why `-p` is unsupported on z/OS,
>
> then I'm good with leaving it at that.
>
> Otherwise, we should make this into an NFC patch that adds the test/adjusts 
> the comments.



1. There is no test for z/OS. `clang/test/Driver/p.c` exists but does not 
contain a z/OS test case.
2. There are no comments explaining why `-p` is unsupported. Removing support 
for `-p` came with D138255 , which simply 
states that `-p` is only supported on AIX and OpenBSD.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

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


[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-12-05 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 480130.
francii marked an inline comment as not done.
francii added a comment.

Remove -p references


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,4 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,4 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-11-22 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 477241.
francii added a comment.

Fix test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: unsupported option '-p' for target 's390x-none-zos'
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck -check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: unsupported option '-p' for target 's390x-none-zos'
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-11-22 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

I will add the missing `e` in the `error:` momentarily.




Comment at: clang/test/Driver/zos-profiling-error.c:7
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: rror: unsupported option '-pg' for target 's390x-none-zos'

I will add the missing `e` in `error:` momentarily.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

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


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-22 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D137375#3943751 , @cebowleratibm 
wrote:

> Looks good but I just want to confirm that the profiled -L paths are appended 
> in the correct order with respect to the non-profiled paths.

The linker gives priority to the libraries that are linked last, in the sense 
that if I link 2 directories with the same library, the library that gets 
linked against is chosen from the second directory, not the first. This patch 
makes the profiled libraries the last to be linked against, so that their 
linking overwrites the linking of their non-profiled counterparts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

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


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-18 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 476649.
francii added a comment.

Remove Linux changes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -7388,7 +7389,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -923,7 +923,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
 CodeGenOpts.InstrumentFunctionEntryBare ||
 CodeGenOpts.InstrumentFunctionsAfterInlining ||
-CodeGenOpts.InstrumentForProfiling) {
+CodeGenOpts.InstrumentForProfiling ||
+CodeGenOpts.InstrumentForProfilingGraph) {
   PB.registerPipelineStartEPCallback(
   [](ModulePassManager , OptimizationLevel Level) {
 MPM.addPass(createModuleToFunctionPassAdaptor(
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4094,8 +4094,10 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, MarshallingInfoFlag>;
-def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>,
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation 

[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-18 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D137753#3935391 , @MaskRay wrote:

> In D137753#3935305 , @francii wrote:
>
>> Recall that the goal with `-p` is to create parity with GCC (at least with 
>> Linux and AIX), as per the RFC discussion.
>>
>> In D137753#3935138 , @MaskRay 
>> wrote:
>>
>>> In D137753#3935126 , @francii 
>>> wrote:
>>>
 In D137753#3934932 , @MaskRay 
 wrote:

> Please make `-p` accepted for AIX only and don't change the semantics for 
> other targets in this patch. For FreeBSD and Linux (musl and gnu) we can 
> try rejecting `-p`. If OpenBSD wants to make `-p` an alias for `-pg`, 
> that's fine.

 We can make `-p` emit a message on Linux while also accepting it as an 
 alias to `-pg`. Do you have a suggestion as to what that message would be?
>>>
>>> The current `warning: argument unused during compilation: '-p' 
>>> [-Wunused-command-line-argument]` is good for Linux.
>>> In the future Linux can try removing `-p`.
>>
>> The current behaviour of ignoring the option without stopping with an error 
>> return code is not a good one.
>>
>> Recall that the goal is to create parity with GCC, as per the RFC post.
>>
>> Is there a reason this flag shouldn't be supported on Linux? Specifically, 
>> what is your justification for diverging from GCC on this matter?
>
> It's a legacy option (at least for Linux, FreeBSD, etc) and we don't want the 
> usage to grow. I objected in the RFC, either. Note that the objection is not 
> only from me, also from a Linux distro folk I checked with.

If we aren't adding Linux functionality, we should make it throw an error at 
the same time.

Once again, ignoring the option without stopping with an error code is not 
ideal.

I can update this patch to throw an error, much like this patch for z/OS: 
https://reviews.llvm.org/D137756

In D137753#3935674 , @MaskRay wrote:

> In D137753#3935617 , @francii wrote:
>
>> In D137753#3935391 , @MaskRay 
>> wrote:
>>
>>> In D137753#3935305 , @francii 
>>> wrote:
>>>
 Recall that the goal with `-p` is to create parity with GCC (at least with 
 Linux and AIX), as per the RFC discussion.

 In D137753#3935138 , @MaskRay 
 wrote:

> In D137753#3935126 , @francii 
> wrote:
>
>> In D137753#3934932 , @MaskRay 
>> wrote:
>>
>>> Please make `-p` accepted for AIX only and don't change the semantics 
>>> for other targets in this patch. For FreeBSD and Linux (musl and gnu) 
>>> we can try rejecting `-p`. If OpenBSD wants to make `-p` an alias for 
>>> `-pg`, that's fine.
>>
>> We can make `-p` emit a message on Linux while also accepting it as an 
>> alias to `-pg`. Do you have a suggestion as to what that message would 
>> be?
>
> The current `warning: argument unused during compilation: '-p' 
> [-Wunused-command-line-argument]` is good for Linux.
> In the future Linux can try removing `-p`.

 The current behaviour of ignoring the option without stopping with an 
 error return code is not a good one.

 Recall that the goal is to create parity with GCC, as per the RFC post.

 Is there a reason this flag shouldn't be supported on Linux? Specifically, 
 what is your justification for diverging from GCC on this matter?
>>>
>>> It's a legacy option (at least for Linux, FreeBSD, etc) and we don't want 
>>> the usage to grow. I objected in the RFC, either. Note that the objection 
>>> is not only from me, also from a Linux distro folk I checked with.
>>
>> If we aren't adding Linux functionality, we should make it throw an error at 
>> the same time.
>>
>> Once again, ignoring the option without stopping with an error code is not 
>> ideal. I can update this patch to throw an error on Linux, much like this 
>> patch for z/OS: https://reviews.llvm.org/D137756
>
> I acknowledge that the current state is bad. Reject it for FreeBSD/Linux 
> (perhaps most OSes. An OS can opt in if their platform really needs this) is 
> likely fine. I don't think `-p` has many uses.
>
> Something like D137756  will be nice, but I 
> think it can be done in clang/lib/Driver/ToolChains/Clang.cpp: D138255 
> 

Thank you, I will remove the Linux/Gnu changes from this patch shortly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-17 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D137753#3935391 , @MaskRay wrote:

> In D137753#3935305 , @francii wrote:
>
>> Recall that the goal with `-p` is to create parity with GCC (at least with 
>> Linux and AIX), as per the RFC discussion.
>>
>> In D137753#3935138 , @MaskRay 
>> wrote:
>>
>>> In D137753#3935126 , @francii 
>>> wrote:
>>>
 In D137753#3934932 , @MaskRay 
 wrote:

> Please make `-p` accepted for AIX only and don't change the semantics for 
> other targets in this patch. For FreeBSD and Linux (musl and gnu) we can 
> try rejecting `-p`. If OpenBSD wants to make `-p` an alias for `-pg`, 
> that's fine.

 We can make `-p` emit a message on Linux while also accepting it as an 
 alias to `-pg`. Do you have a suggestion as to what that message would be?
>>>
>>> The current `warning: argument unused during compilation: '-p' 
>>> [-Wunused-command-line-argument]` is good for Linux.
>>> In the future Linux can try removing `-p`.
>>
>> The current behaviour of ignoring the option without stopping with an error 
>> return code is not a good one.
>>
>> Recall that the goal is to create parity with GCC, as per the RFC post.
>>
>> Is there a reason this flag shouldn't be supported on Linux? Specifically, 
>> what is your justification for diverging from GCC on this matter?
>
> It's a legacy option (at least for Linux, FreeBSD, etc) and we don't want the 
> usage to grow. I objected in the RFC, either. Note that the objection is not 
> only from me, also from a Linux distro folk I checked with.

If we aren't adding Linux functionality, we should make it throw an error at 
the same time.

Once again, ignoring the option without stopping with an error code is not 
ideal. I can update this patch to throw an error on Linux, much like this patch 
for z/OS: https://reviews.llvm.org/D137756


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

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


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-17 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

Recall that the goal with `-p` is to create parity with GCC (at least with 
Linux and AIX), as per the RFC discussion.

In D137753#3935138 , @MaskRay wrote:

> In D137753#3935126 , @francii wrote:
>
>> In D137753#3934932 , @MaskRay 
>> wrote:
>>
>>> Please make `-p` accepted for AIX only and don't change the semantics for 
>>> other targets in this patch. For FreeBSD and Linux (musl and gnu) we can 
>>> try rejecting `-p`. If OpenBSD wants to make `-p` an alias for `-pg`, 
>>> that's fine.
>>
>> We can make `-p` emit a message on Linux while also accepting it as an alias 
>> to `-pg`. Do you have a suggestion as to what that message would be?
>
> The current `warning: argument unused during compilation: '-p' 
> [-Wunused-command-line-argument]` is good for Linux.
> In the future Linux can try removing `-p`.

The current behaviour of ignoring the option without stopping with an error 
return code is not a good one.

Recall that the goal is to create parity with GCC, as per the RFC post.

Is there a reason this flag shouldn't be supported on Linux? Specifically, what 
is your justification for diverging from GCC on this matter?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

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


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-17 Thread Michael Francis via Phabricator via cfe-commits
francii added a comment.

In D137753#3934932 , @MaskRay wrote:

> Please make `-p` accepted for AIX only and don't change the semantics for 
> other targets in this patch. For FreeBSD and Linux (musl and gnu) we can try 
> rejecting `-p`. If OpenBSD wants to make `-p` an alias for `-pg`, that's fine.

We can make `-p` emit a message on Linux while also accepting it as an alias to 
`-pg`. Do you have a suggestion as to what that message would be?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

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


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-17 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 476203.
francii added a comment.

Specify prof and gprof in help text


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is 

[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475242.
francii added a comment.

Add sysroot check to aix-ld.c test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" 

[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475203.
francii added a comment.

Add sysroot to test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-GPROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475197.
francii added a comment.

Remove check for -p


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475196.
francii added a comment.

Add profiled libraries check AIX


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aix-ld.c
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L/lib/profiled"
+// CHECK-LD32-PROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L/lib/profiled"
+// CHECK-LD64-PROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // 

[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475194.
francii added a comment.

Fix mixup


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -189,6 +189,8 @@
 // CHECK-LD32-GPROF-NOT: "--no-as-needed"
 // CHECK-LD32-GPROF-NOT: "-lm"
 // CHECK-LD32-GPROF: "-lc"
+// CHECK-LD32-GPROF: "-L/lib/profiled"
+// CHECK-LD32-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -216,6 +218,8 @@
 // CHECK-LD64-GPROF-NOT: "--no-as-needed"
 // CHECK-LD64-GPROF-NOT: "-lm"
 // CHECK-LD64-GPROF: "-lc"
+// CHECK-LD64-GPROF: "-L/lib/profiled"
+// CHECK-LD64-GPROF: "-L/usr/lib/profiled"
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Static linking.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-14 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475187.
francii added a comment.
Herald added a subscriber: ormris.

Removed check for sysroot, it is not needed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,13 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+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) +
+   "/usr/lib/profiled"));
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -923,7 +923,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
 CodeGenOpts.InstrumentFunctionEntryBare ||
 CodeGenOpts.InstrumentFunctionsAfterInlining ||
-CodeGenOpts.InstrumentForProfiling) {
+

[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475009.
francii added a comment.

Updated Linux test case
Added profiled library search for AIX.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,18 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  if (!D.SysRoot.empty()) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
+  } else {
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
+  }
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -923,7 +923,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
 

[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475007.
francii added a comment.

Soft reset


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,18 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  if (!D.SysRoot.empty()) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
+  } else {
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
+  }
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,18 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  if (!D.SysRoot.empty()) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
+  } else {
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
+  }
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475006.
francii added a comment.

Removed unnecessary variables


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -245,20 +245,15 @@
 CmdArgs.push_back("-lc");
 
 if (Args.hasArg(options::OPT_pg)) {
-  const char *libProfiled;
-  const char *usrLibProfiled;
-
   if (!D.SysRoot.empty()) {
-libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
- "/lib/profiled");
-usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
-"/usr/lib/profiled");
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
   } else {
-libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
-usrLibProfiled = 
Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
   }
-  CmdArgs.push_back(libProfiled);
-  CmdArgs.push_back(usrLibProfiled);
 }
   }
 


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -245,20 +245,15 @@
 CmdArgs.push_back("-lc");
 
 if (Args.hasArg(options::OPT_pg)) {
-  const char *libProfiled;
-  const char *usrLibProfiled;
-
   if (!D.SysRoot.empty()) {
-libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
- "/lib/profiled");
-usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
-"/usr/lib/profiled");
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
   } else {
-libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
-usrLibProfiled = Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
   }
-  CmdArgs.push_back(libProfiled);
-  CmdArgs.push_back(usrLibProfiled);
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475005.
francii added a comment.

Add support for `--sysroot`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137375/new/

https://reviews.llvm.org/D137375

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


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,23 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  const char *libProfiled;
+  const char *usrLibProfiled;
+
+  if (!D.SysRoot.empty()) {
+libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled");
+usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+"/usr/lib/profiled");
+  } else {
+libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
+usrLibProfiled = 
Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+  }
+  CmdArgs.push_back(libProfiled);
+  CmdArgs.push_back(usrLibProfiled);
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,23 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  const char *libProfiled;
+  const char *usrLibProfiled;
+
+  if (!D.SysRoot.empty()) {
+libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled");
+usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+"/usr/lib/profiled");
+  } else {
+libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
+usrLibProfiled = Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+  }
+  CmdArgs.push_back(libProfiled);
+  CmdArgs.push_back(usrLibProfiled);
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][GNU][AIX}[p]Enable -p Functionality

2022-11-10 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 474604.
francii added a comment.

Added Linux implementation and test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137753/new/

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-PG %s
+// CHECK-PG: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -923,7 +923,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
 CodeGenOpts.InstrumentFunctionEntryBare ||
 CodeGenOpts.InstrumentFunctionsAfterInlining ||
-CodeGenOpts.InstrumentForProfiling) {
+CodeGenOpts.InstrumentForProfiling ||
+CodeGenOpts.InstrumentForProfilingGraph) {
   PB.registerPipelineStartEPCallback(
   [](ModulePassManager , OptimizationLevel Level) {
 MPM.addPass(createModuleToFunctionPassAdaptor(
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4094,8 +4094,10 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, MarshallingInfoFlag>;
-def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>,
+def p : Flag<["-"], 

[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-11-09 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 474440.
francii added a comment.

Use existing error


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137756/new/

https://reviews.llvm.org/D137756

Files:
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: unsupported option '-p' for target 's390x-none-zos'
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: rror: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck -check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: unsupported option '-p' for target 's390x-none-zos'
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: rror: unsupported option '-pg' for target 's390x-none-zos'
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,13 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+<< ArgString << Triple.getTriple();
+  }
+}
 
 ZOS::~ZOS() {}
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137756: [z/OS][p][pg] Throw Error When Using -p or -pg on z/OS

2022-11-09 Thread Michael Francis via Phabricator via cfe-commits
francii created this revision.
Herald added a project: All.
francii requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Throw an error when trying to compile with `-p` or `-pg` on z/OS,
as the platform does not support `prof` and `gprof`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137756

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/test/Driver/zos-profiling-error.c


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: the clang compiler does not support the '-p' option on 
z/OS.
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck 
-check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: the clang compiler does not support the '-pg' option 
on z/OS.
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,12 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_option_unsupported_zos) << ArgString;
+  }
+}
 
 ZOS::~ZOS() {}
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -237,6 +237,9 @@
 def err_arch_unsupported_isa
   : Error<"architecture '%0' does not support '%1' execution mode">;
 
+def err_option_unsupported_zos: Error<
+  "the clang compiler does not support the '%0' option on z/OS.">;
+
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;
 def err_drv_unknown_argument : Error<"unknown argument: '%0'">;


Index: clang/test/Driver/zos-profiling-error.c
===
--- /dev/null
+++ clang/test/Driver/zos-profiling-error.c
@@ -0,0 +1,7 @@
+// Check failed cases
+
+// RUN: not %clang -target s390x-none-zos -p -S %s 2>&1 | FileCheck -check-prefix=FAIL-P-NAME %s
+// FAIL-P-NAME: error: the clang compiler does not support the '-p' option on z/OS.
+
+// RUN: not %clang -target s390x-none-zos -pg -S %s 2>&1 | FileCheck -check-prefix=FAIL-PG-NAME %s
+// FAIL-PG-NAME: error: the clang compiler does not support the '-pg' option on z/OS.
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- clang/lib/Driver/ToolChains/ZOS.cpp
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -18,7 +18,12 @@
 using namespace clang;
 
 ZOS::ZOS(const Driver , const llvm::Triple , const ArgList )
-: ToolChain(D, Triple, Args) {}
+: ToolChain(D, Triple, Args) {
+  for (Arg *A : Args.filtered(options::OPT_p, options::OPT_pg)) {
+auto ArgString = A->getAsString(Args);
+this->getDriver().Diag(diag::err_option_unsupported_zos) << ArgString;
+  }
+}
 
 ZOS::~ZOS() {}
 
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -237,6 +237,9 @@
 def err_arch_unsupported_isa
   : Error<"architecture '%0' does not support '%1' execution mode">;
 
+def err_option_unsupported_zos: Error<
+  "the clang compiler does not support the '%0' option on z/OS.">;
+
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;
 def err_drv_unknown_argument : Error<"unknown argument: '%0'">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >