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.
With this patch, if both -p and -pg are passed, the argument that is passed second will take precedence. -p will still throw an error on unsupported platforms, regardless of precedence.
This revision includes a test case, which has been placed in clang/test/Driver/zos-profiling-error.c. As a result, zos-profiling-error.c has been renamed to ibm-profiling.c. This revision also passes clang/test/Driver/aix-ld.c.
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.