summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp8
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp11
-rw-r--r--clang/test/CodeGen/mnop-mcount.c3
-rw-r--r--clang/test/CodeGen/mrecord-mcount.c3
-rw-r--r--clang/test/Driver/mcount.c8
5 files changed, 17 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 6f7e06b773d..0f90f6ecf5b 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -959,10 +959,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
getTarget().getMCountName());
}
if (CGM.getCodeGenOpts().MNopMCount) {
- if (getContext().getTargetInfo().getTriple().getArch() !=
- llvm::Triple::systemz)
- CGM.getDiags().Report(diag::err_opt_not_valid_on_target)
- << "-mnop-mcount";
if (!CGM.getCodeGenOpts().CallFEntry)
CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
<< "-mnop-mcount" << "-mfentry";
@@ -970,10 +966,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
}
if (CGM.getCodeGenOpts().RecordMCount) {
- if (getContext().getTargetInfo().getTriple().getArch() !=
- llvm::Triple::systemz)
- CGM.getDiags().Report(diag::err_opt_not_valid_on_target)
- << "-mrecord-mcount";
if (!CGM.getCodeGenOpts().CallFEntry)
CGM.getDiags().Report(diag::err_opt_not_valid_without_opt)
<< "-mrecord-mcount" << "-mfentry";
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 2ebfc763705..03100948f56 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4995,8 +4995,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (TC.SupportsProfiling())
Args.AddLastArg(CmdArgs, options::OPT_mnop_mcount);
- if (TC.SupportsProfiling())
- Args.AddLastArg(CmdArgs, options::OPT_mrecord_mcount);
+ if (TC.SupportsProfiling()) {
+ if (Arg *A = Args.getLastArg(options::OPT_mrecord_mcount)) {
+ if (TC.getArch() == llvm::Triple::systemz)
+ A->render(Args, CmdArgs);
+ else
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getAsString(Args) << TripleStr;
+ }
+ }
Args.AddLastArg(CmdArgs, options::OPT_mpacked_stack);
diff --git a/clang/test/CodeGen/mnop-mcount.c b/clang/test/CodeGen/mnop-mcount.c
index a6b10b62505..ebb21cc560e 100644
--- a/clang/test/CodeGen/mnop-mcount.c
+++ b/clang/test/CodeGen/mnop-mcount.c
@@ -6,8 +6,6 @@
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
// RUN: %clang_cc1 -mnop-mcount -triple s390x-ibm-linux -emit-llvm -o - %s \
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
-// RUN: not %clang_cc1 -pg -mfentry -mnop-mcount -triple x86_64-linux-gnu \
-// RUN: -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=X86 %s
int foo(void) {
return 0;
@@ -23,4 +21,3 @@ int __attribute__((no_instrument_function)) no_instrument(void) {
//NOMFENTRY: error: option '-mnop-mcount' cannot be specified without '-mfentry'
//NOPG-NOT: attributes #0 = { {{.*}}"mnop-mcount"{{.*}} }
//NOPG-NOT: attributes #1 = { {{.*}}"mnop-mcount"{{.*}} }
-//X86: error: option '-mnop-mcount' cannot be specified on this target
diff --git a/clang/test/CodeGen/mrecord-mcount.c b/clang/test/CodeGen/mrecord-mcount.c
index eecee0e24cd..292a807073c 100644
--- a/clang/test/CodeGen/mrecord-mcount.c
+++ b/clang/test/CodeGen/mrecord-mcount.c
@@ -6,8 +6,6 @@
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
// RUN: %clang_cc1 -mrecord-mcount -triple s390x-ibm-linux -emit-llvm -o - %s \
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
-// RUN: not %clang_cc1 -pg -mfentry -mrecord-mcount -triple x86_64-linux-gnu \
-// RUN: -emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=X86 %s
int foo(void) {
return 0;
@@ -23,4 +21,3 @@ int __attribute__((no_instrument_function)) no_instrument(void) {
//NOMFENTRY: error: option '-mrecord-mcount' cannot be specified without '-mfentry'
//NOPG-NOT: attributes #0 = { {{.*}}"mrecord-mcount"{{.*}} }
//NOPG-NOT: attributes #1 = { {{.*}}"mrecord-mcount"{{.*}} }
-//X86: error: option '-mrecord-mcount' cannot be specified on this target
diff --git a/clang/test/Driver/mcount.c b/clang/test/Driver/mcount.c
new file mode 100644
index 00000000000..7086abfc74b
--- /dev/null
+++ b/clang/test/Driver/mcount.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target s390x -c -### %s -mrecord-mcount 2>&1 | FileCheck %s
+// CHECK: "-mrecord-mcount"
+
+// RUN: %clang -target x86_64 -c -### %s -mrecord-mcount 2>&1 | FileCheck --check-prefix=ERR1 %s
+// RUN: %clang -target aarch64 -c -### %s -mrecord-mcount 2>&1 | FileCheck --check-prefix=ERR2 %s
+
+// ERR1: error: unsupported option '-mrecord-mcount' for target 'x86_64'
+// ERR2: error: unsupported option '-mrecord-mcount' for target 'aarch64'
OpenPOWER on IntegriCloud