Skip to content

Commit 27616c7

Browse files
committed
[clang] enable -mnop-mcount -mrecord-mcount for x86_64
These are gated by -mfentry.
1 parent 1d7b9d7 commit 27616c7

4 files changed

Lines changed: 21 additions & 5 deletions

File tree

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6884,14 +6884,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
68846884
<< A->getAsString(Args) << TripleStr;
68856885
}
68866886
if (Arg *A = Args.getLastArg(options::OPT_mnop_mcount)) {
6887-
if (Arch == llvm::Triple::systemz)
6887+
if (Arch == llvm::Triple::systemz ||
6888+
(TC.getTriple().isX86_64() && TC.getTriple().isOSBinFormatELF()))
68886889
A->render(Args, CmdArgs);
68896890
else
68906891
D.Diag(diag::err_drv_unsupported_opt_for_target)
68916892
<< A->getAsString(Args) << TripleStr;
68926893
}
68936894
if (Arg *A = Args.getLastArg(options::OPT_mrecord_mcount)) {
6894-
if (Arch == llvm::Triple::systemz)
6895+
if (Arch == llvm::Triple::systemz ||
6896+
(TC.getTriple().isX86_64() && TC.getTriple().isOSBinFormatELF()))
68956897
A->render(Args, CmdArgs);
68966898
else
68976899
D.Diag(diag::err_drv_unsupported_opt_for_target)

clang/test/CodeGen/mnop-mcount.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
77
// RUN: %clang_cc1 -mnop-mcount -triple s390x-ibm-linux -emit-llvm -o - %s \
88
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
9+
// RUN: %clang_cc1 -pg -mfentry -mnop-mcount -triple x86_64-ibm-linux -emit-llvm \
10+
// RUN: -o - %s 2>&1 | FileCheck %s
11+
// RUN: not %clang_cc1 -pg -mnop-mcount -triple x86_64-ibm-linux -emit-llvm -o - \
12+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOMFENTRY %s
13+
// RUN: %clang_cc1 -mfentry -mnop-mcount -triple x86_64-ibm-linux -emit-llvm -o - \
14+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
15+
// RUN: %clang_cc1 -mnop-mcount -triple x86_64-ibm-linux -emit-llvm -o - %s \
16+
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
917

1018
int foo(void) {
1119
return 0;

clang/test/CodeGen/mrecord-mcount.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
77
// RUN: %clang_cc1 -mrecord-mcount -triple s390x-ibm-linux -emit-llvm -o - %s \
88
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
9+
// RUN: %clang_cc1 -pg -mfentry -mrecord-mcount -triple x86_64-ibm-linux -emit-llvm \
10+
// RUN: -o - %s 2>&1 | FileCheck %s
11+
// RUN: not %clang_cc1 -pg -mrecord-mcount -triple x86_64-ibm-linux -emit-llvm -o - \
12+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOMFENTRY %s
13+
// RUN: %clang_cc1 -mfentry -mrecord-mcount -triple x86_64-ibm-linux -emit-llvm -o - \
14+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
15+
// RUN: %clang_cc1 -mrecord-mcount -triple x86_64-ibm-linux -emit-llvm -o - %s \
16+
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
917

1018
int foo(void) {
1119
return 0;

clang/test/Driver/mcount.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// RUN: %clang --target=s390x -c -### %s -mnop-mcount -mrecord-mcount 2>&1 | FileCheck %s
2+
// RUN: %clang --target=x86_64 -c -### %s -mnop-mcount -mrecord-mcount 2>&1 | FileCheck %s
23

34
// CHECK: "-mnop-mcount"
45
// CHECK: "-mrecord-mcount"
56

6-
// RUN: not %clang --target=x86_64 -c -### %s -mnop-mcount -mrecord-mcount 2>&1 | FileCheck --check-prefix=ERR1 %s
77
// RUN: not %clang --target=aarch64 -c -### %s -mnop-mcount -mrecord-mcount 2>&1 | FileCheck --check-prefix=ERR2 %s
88

9-
// ERR1: error: unsupported option '-mnop-mcount' for target 'x86_64'
10-
// ERR1: error: unsupported option '-mrecord-mcount' for target 'x86_64'
119
// ERR2: error: unsupported option '-mnop-mcount' for target 'aarch64'
1210
// ERR2: error: unsupported option '-mrecord-mcount' for target 'aarch64'

0 commit comments

Comments
 (0)