From patchwork Thu Oct 22 13:21:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Bin X-Patchwork-Id: 55440 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lf0-f69.google.com (mail-lf0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 70E7620581 for ; Thu, 22 Oct 2015 13:23:33 +0000 (UTC) Received: by lffv3 with SMTP id v3sf32705536lff.1 for ; Thu, 22 Oct 2015 06:23:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:from:to:cc:subject:date:message-id:mime-version :content-type:x-original-sender:x-original-authentication-results; bh=Tg3c5vaVDOerjsKaNGiTidYrLJMr8nUR+GptBoVdVkE=; b=SwwM28W1ZtqjWBlkkquRiiQnr1rrIX6JLIwTARD5/F+c01lpoYRxTit+O7QFa60WGg K4pytr3gaSIvFfnAT89WoR1Zf3IEMiUAnXqQcNmnSsdPcvLWd9aPb4ol6A6URYtQmkr2 uHpXNGZ2+JX6sLG6EfOhpwp4DdQ5uInB/CBG5VddKai6R/OqMFEBdGa+K/iafBQ0AVXR PDGgUEKs7pU0rEGVssC1xLX7jvWXJ8//54Lbxlt7giRO+UanWwaoKXO5KkMGA9xfT4rv H+bhpijGkZDUU4274daX8MCr9jxTgBbFDW9XjFFisYO14/3v4qzhP2j2be/wKCL3PPmr KRhw== X-Gm-Message-State: ALoCoQnqthFV2dJLp+Cac8XrPuzk0lyczMUJ5Bl6J91+fnCL443wd4ADn1Vj5J72ntLjP8E0+rX7 X-Received: by 10.180.210.212 with SMTP id mw20mr8348204wic.3.1445520212319; Thu, 22 Oct 2015 06:23:32 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.39.77 with SMTP id n74ls46744lfn.36.gmail; Thu, 22 Oct 2015 06:23:32 -0700 (PDT) X-Received: by 10.112.32.72 with SMTP id g8mr8302094lbi.22.1445520212195; Thu, 22 Oct 2015 06:23:32 -0700 (PDT) Received: from mail-lf0-x231.google.com (mail-lf0-x231.google.com. [2a00:1450:4010:c07::231]) by mx.google.com with ESMTPS id e102si9617518lfi.75.2015.10.22.06.23.32 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 06:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) client-ip=2a00:1450:4010:c07::231; Received: by lffz202 with SMTP id z202so47711037lff.3 for ; Thu, 22 Oct 2015 06:23:32 -0700 (PDT) X-Received: by 10.112.202.35 with SMTP id kf3mr8566506lbc.19.1445520212078; Thu, 22 Oct 2015 06:23:32 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp604208lbq; Thu, 22 Oct 2015 06:23:31 -0700 (PDT) X-Received: by 10.50.107.104 with SMTP id hb8mr15631503igb.1.1445520211073; Thu, 22 Oct 2015 06:23:31 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id l102si11189384iod.201.2015.10.22.06.23.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Oct 2015 06:23:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-411030-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 19247 invoked by alias); 22 Oct 2015 13:23:10 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 19238 invoked by uid 89); 22 Oct 2015 13:23:10 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.9 required=5.0 tests=AWL, BAYES_50, KAM_STOCKGEN, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 X-HELO: szxga02-in.huawei.com Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 22 Oct 2015 13:23:08 +0000 Received: from 172.24.1.48 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.48]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CUV30488; Thu, 22 Oct 2015 21:22:46 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Thu, 22 Oct 2015 21:22:34 +0800 From: Li Bin To: CC: , , , , , , Subject: [PATCH] [AArch64] support -mfentry feature for arm64 Date: Thu, 22 Oct 2015 21:21:53 +0800 Message-ID: <1445520113-1797-1-git-send-email-huawei.libin@huawei.com> MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c07::231 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 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(-) 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.