From patchwork Mon Mar 14 08:14:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Bin X-Patchwork-Id: 63795 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2343040lbc; Mon, 14 Mar 2016 01:13:13 -0700 (PDT) X-Received: by 10.98.17.74 with SMTP id z71mr28316365pfi.30.1457943193664; Mon, 14 Mar 2016 01:13:13 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id qz9si23471739pab.94.2016.03.14.01.13.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Mar 2016 01:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-423183-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-return-423183-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-423183-patch=linaro.org@gcc.gnu.org; dkim=pass header.i=@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=ALkFojN0UVyusyWQ H9LzL8wMzmaI8UGLnCLggf037Fa1I6nDI5LjkDF8mgrCsNmuEnTkG5m7hFS42n5d gSzS1LM9RNDeuy3cme+prT7nwB8PWm4lmD7XINbHJpP87ohDOOA84o31WTIhbvyi kSNhI+HkCeXyNcyVEDF5VY/c1oA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=DuQUyN1wgfrgmbM1Aj8AYi DQIWs=; b=w95x96RcqSkRWy69RPIyq3wvnQZqFVVLtng2DG24RxD0W/z2AgpnTo X/Hes5Vvb9HaCfujnIEM9+CSEc9Vmw0ejCr8re8B8z0341TQI1E0r91iTz8i8d5/ eHv/HAB+A5nShW9E3cEQ6EIfFOph8eHe4Su1Y9OG4hoPLBVifLmTI= Received: (qmail 107687 invoked by alias); 14 Mar 2016 08:12:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 107671 invoked by uid 89); 14 Mar 2016 08:12:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.3 required=5.0 tests=BAYES_50, KAM_STOCKGEN, SPF_PASS autolearn=no version=3.3.2 spammy=String, Enum, 171, Bin X-HELO: szxga03-in.huawei.com Received: from Unknown (HELO szxga03-in.huawei.com) (119.145.14.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Mon, 14 Mar 2016 08:12:44 +0000 Received: from 172.24.1.48 (EHLO szxeml432-hub.china.huawei.com) ([172.24.1.48]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BXY33939; Mon, 14 Mar 2016 16:11:18 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.235.1; Mon, 14 Mar 2016 16:11:08 +0800 From: Li Bin To: CC: , , , , , , , , , , Subject: [PATCH] [AArch64] support -mfentry feature for arm64 Date: Mon, 14 Mar 2016 16:14:20 +0800 Message-ID: <1457943260-30894-2-git-send-email-huawei.libin@huawei.com> In-Reply-To: <1457943260-30894-1-git-send-email-huawei.libin@huawei.com> References: <1457943260-30894-1-git-send-email-huawei.libin@huawei.com> MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.56E67227.007A, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 980cd481060799602b04a9cf1936a5fc From: Jiangjiji * 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 Signed-off-by: Li Bin --- 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(-) -- 1.7.1 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.