[PATCH] D74698: [CodeGen] -pg shouldn't add "frame-pointer"="all" fn attr w/ -mfentry
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 16 21:37:43 PST 2020
nickdesaulniers created this revision.
nickdesaulniers added reviewers: void, manojgupta, dberris.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
$ clang -O2 -pg -mfentry foo.c
was adding frame pointers to all functions. This was exposed via
compiling the Linux kernel for x86_64 with CONFIG_FUNCTION_TRACER
enabled.
Fixes: pr/44934
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74698
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/fentry.c
Index: clang/test/CodeGen/fentry.c
===================================================================
--- clang/test/CodeGen/fentry.c
+++ clang/test/CodeGen/fentry.c
@@ -2,6 +2,7 @@
// RUN: %clang_cc1 -pg -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -mfentry -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck -check-prefix=NOPG %s
// RUN: %clang_cc1 -mfentry -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=NOPG %s
+// RUN: %clang_cc1 -pg -mfentry -emit-llvm -o - %s | FileCheck -check-prefix=NOFP %s
int foo(void) {
return 0;
@@ -16,3 +17,4 @@
//CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
//NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
//NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
+//NOFP-NOT: "frame-pointer"="all"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -526,7 +526,7 @@
static bool useFramePointerForTargetByDefault(const ArgList &Args,
const llvm::Triple &Triple) {
- if (Args.hasArg(options::OPT_pg))
+ if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
return true;
switch (Triple.getArch()) {
@@ -6150,7 +6150,8 @@
}
if (Arg *A = Args.getLastArg(options::OPT_pg))
- if (FPKeepKind == CodeGenOptions::FramePointerKind::None)
+ if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
+ !Args.hasArg(options::OPT_mfentry))
D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
<< A->getAsString(Args);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74698.244915.patch
Type: text/x-patch
Size: 1808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200217/88aba1f5/attachment.bin>
More information about the cfe-commits
mailing list