Skip to content

Commit aae9774

Browse files
committed
[clang] enable -mnop-mcount -mrecord-mcount for x86
These are gated by -mfentry.
1 parent d615adb commit aae9774

4 files changed

Lines changed: 38 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() && 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() && 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
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-unknown-linux -emit-llvm \
10+
// RUN: -o - %s 2>&1 | FileCheck %s
11+
// RUN: not %clang_cc1 -pg -mnop-mcount -triple x86_64-unknown-linux -emit-llvm -o - \
12+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOMFENTRY %s
13+
// RUN: %clang_cc1 -mfentry -mnop-mcount -triple x86_64-unknown-linux -emit-llvm -o - \
14+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
15+
// RUN: %clang_cc1 -mnop-mcount -triple x86_64-unknown-linux -emit-llvm -o - %s \
16+
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
17+
// RUN: %clang_cc1 -pg -mfentry -mnop-mcount -triple i686-unknown-linux -emit-llvm \
18+
// RUN: -o - %s 2>&1 | FileCheck %s
19+
// RUN: not %clang_cc1 -pg -mnop-mcount -triple i686-unknown-linux -emit-llvm -o - \
20+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOMFENTRY %s
21+
// RUN: %clang_cc1 -mfentry -mnop-mcount -triple i686-unknown-linux -emit-llvm -o - \
22+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
23+
// RUN: %clang_cc1 -mnop-mcount -triple i686-unknown-linux -emit-llvm -o - %s \
24+
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
925

1026
int foo(void) {
1127
return 0;

clang/test/CodeGen/mrecord-mcount.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
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-unknown-linux -emit-llvm \
10+
// RUN: -o - %s 2>&1 | FileCheck %s
11+
// RUN: not %clang_cc1 -pg -mrecord-mcount -triple x86_64-unknown-linux -emit-llvm -o - \
12+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOMFENTRY %s
13+
// RUN: %clang_cc1 -mfentry -mrecord-mcount -triple x86_64-unknown-linux -emit-llvm -o - \
14+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
15+
// RUN: %clang_cc1 -mrecord-mcount -triple x86_64-unknown-linux -emit-llvm -o - %s \
16+
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
17+
// RUN: %clang_cc1 -pg -mfentry -mrecord-mcount -triple i686-unknown-linux -emit-llvm \
18+
// RUN: -o - %s 2>&1 | FileCheck %s
19+
// RUN: not %clang_cc1 -pg -mrecord-mcount -triple i686-unknown-linux -emit-llvm -o - \
20+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOMFENTRY %s
21+
// RUN: %clang_cc1 -mfentry -mrecord-mcount -triple i686-unknown-linux -emit-llvm -o - \
22+
// RUN: %s 2>&1 | FileCheck -check-prefix=NOPG %s
23+
// RUN: %clang_cc1 -mrecord-mcount -triple i686-unknown-linux -emit-llvm -o - %s \
24+
// RUN: 2>&1 | FileCheck -check-prefix=NOPG %s
925

1026
int foo(void) {
1127
return 0;

clang/test/Driver/mcount.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
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
3+
// RUN: %clang --target=i686 -c -### %s -mnop-mcount -mrecord-mcount 2>&1 | FileCheck %s
24

35
// CHECK: "-mnop-mcount"
46
// CHECK: "-mrecord-mcount"
57

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

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

0 commit comments

Comments
 (0)