From: Li Bin <huawei.libin@huawei.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <szabolcs.nagy@arm.com>, <Geoff.Levand@huawei.com>,
<Andrew.Wafaa@arm.com>, <guohanjun@huawei.com>,
<felix.yang@huawei.com>, <jiangjiji@huawei.com>,
<huawei.libin@huawei.com>
Subject: [PATCH] [AArch64] support -mfentry feature for arm64
Date: Thu, 22 Oct 2015 13:24:00 -0000 [thread overview]
Message-ID: <1445520113-1797-1-git-send-email-huawei.libin@huawei.com> (raw)
From: Jiangjiji <jiangjiji@huawei.com>
* gcc/config/aarch64/aarch64.opt: Add a new option.
* gcc/config/aarch64/aarch64.c: Add some new functions and Macros.
* gcc/config/aarch64/aarch64.h: Modify PROFILE_HOOK and FUNCTION_PROFILER.
Signed-off-by: Jiangjiji <jiangjiji@huawei.com>
Signed-off-by: Li Bin <huawei.libin@huawei.com>
---
gcc/config/aarch64/aarch64.c | 23 +++++++++++++++++++++++
gcc/config/aarch64/aarch64.h | 13 ++++++++-----
gcc/config/aarch64/aarch64.opt | 4 ++++
3 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 752df4e..c70b161 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -440,6 +440,17 @@ aarch64_is_long_call_p (rtx sym)
return aarch64_decl_is_long_call_p (SYMBOL_REF_DECL (sym));
}
+void
+aarch64_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED)
+{
+ if (flag_fentry)
+ {
+ fprintf (file, "\tmov\tx9, x30\n");
+ fprintf (file, "\tbl\t__fentry__\n");
+ fprintf (file, "\tmov\tx30, x9\n");
+ }
+}
+
/* Return true if the offsets to a zero/sign-extract operation
represent an expression that matches an extend operation. The
operands represent the paramters from
@@ -7414,6 +7425,15 @@ aarch64_emit_unlikely_jump (rtx insn)
add_int_reg_note (insn, REG_BR_PROB, very_unlikely);
}
+/* Return true, if profiling code should be emitted before
+ * prologue. Otherwise it returns false.
+ * Note: For x86 with "hotfix" it is sorried. */
+static bool
+aarch64_profile_before_prologue (void)
+{
+ return flag_fentry != 0;
+}
+
/* Expand a compare and swap pattern. */
void
@@ -8454,6 +8474,9 @@ aarch64_cannot_change_mode_class (enum machine_mode from,
#undef TARGET_ASM_ALIGNED_SI_OP
#define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
+#undef TARGET_PROFILE_BEFORE_PROLOGUE
+#define TARGET_PROFILE_BEFORE_PROLOGUE aarch64_profile_before_prologue
+
#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
#define TARGET_ASM_CAN_OUTPUT_MI_THUNK \
hook_bool_const_tree_hwi_hwi_const_tree_true
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 77b2bb9..65e34fc 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -804,13 +804,16 @@ do { \
#define PROFILE_HOOK(LABEL) \
{ \
rtx fun, lr; \
- lr = get_hard_reg_initial_val (Pmode, LR_REGNUM); \
- fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME); \
- emit_library_call (fun, LCT_NORMAL, VOIDmode, 1, lr, Pmode); \
+ if (!flag_fentry)
+ {
+ lr = get_hard_reg_initial_val (Pmode, LR_REGNUM); \
+ fun = gen_rtx_SYMBOL_REF (Pmode, MCOUNT_NAME); \
+ emit_library_call (fun, LCT_NORMAL, VOIDmode, 1, lr, Pmode); \
+ }
}
-/* All the work done in PROFILE_HOOK, but still required. */
-#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0)
+#define FUNCTION_PROFILER(STREAM, LABELNO)
+ aarch64_function_profiler(STREAM, LABELNO)
/* For some reason, the Linux headers think they know how to define
these macros. They don't!!! */
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 266d873..9e4b408 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -124,3 +124,7 @@ Enum(aarch64_abi) String(ilp32) Value(AARCH64_ABI_ILP32)
EnumValue
Enum(aarch64_abi) String(lp64) Value(AARCH64_ABI_LP64)
+
+mfentry
+Target Report Var(flag_fentry) Init(0)
+Emit profiling counter call at function entry immediately after prologue.
--
1.7.1
next reply other threads:[~2015-10-22 13:23 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 13:24 Li Bin [this message]
2015-10-22 13:53 ` Marcus Shawcroft
2016-03-14 8:13 Li Bin
2016-03-14 8:12 ` Li Bin
2016-04-14 13:08 ` Maxim Kuvyrkov
2016-04-14 13:15 ` Andrew Pinski
2016-04-14 15:58 ` Szabolcs Nagy
2016-04-18 13:26 ` Alexander Monakov
2016-04-18 13:34 ` Ramana Radhakrishnan
2016-04-18 13:44 ` Alexander Monakov
2016-04-18 13:57 ` Ramana Radhakrishnan
2016-04-18 14:03 ` Alexander Monakov
2016-04-18 14:31 ` Szabolcs Nagy
2016-04-18 15:54 ` Alexander Monakov
2016-04-19 6:46 ` AKASHI Takahiro
2016-04-19 6:13 ` AKASHI Takahiro
2016-04-19 6:44 ` Alexander Monakov
2016-04-20 0:33 ` AKASHI Takahiro
2016-04-20 10:02 ` Szabolcs Nagy
2016-04-15 15:40 ` Michael Matz
2016-04-15 17:29 ` Alexander Monakov
2016-04-17 15:06 ` Alexander Monakov
2016-04-18 12:12 ` Michael Matz
2016-04-19 6:26 ` AKASHI Takahiro
2016-04-19 6:39 ` Alexander Monakov
2016-04-20 1:23 ` AKASHI Takahiro
2016-04-20 16:45 ` Szabolcs Nagy
2016-04-19 16:03 ` Torsten Duwe
2016-04-18 14:32 ` Andrew Haley
2016-04-18 17:13 ` Michael Matz
2016-04-18 17:17 ` Andrew Haley
2016-04-18 17:34 ` Michael Matz
2016-04-19 8:00 ` Andrew Haley
2016-04-19 13:19 ` Michael Matz
2016-04-19 13:25 ` Andrew Haley
2016-04-19 14:38 ` Pedro Alves
2016-04-19 15:02 ` Andrew Haley
2016-04-19 6:08 ` AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445520113-1797-1-git-send-email-huawei.libin@huawei.com \
--to=huawei.libin@huawei.com \
--cc=Andrew.Wafaa@arm.com \
--cc=Geoff.Levand@huawei.com \
--cc=felix.yang@huawei.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=guohanjun@huawei.com \
--cc=jiangjiji@huawei.com \
--cc=szabolcs.nagy@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).