From patchwork Mon Nov 12 11:25:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu X-Patchwork-Id: 996351 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489711-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZopQzBGj"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hX4FxxuD"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42tpN61sJ5z9s7W for ; Mon, 12 Nov 2018 22:25:42 +1100 (AEDT) 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-transfer-encoding; q=dns; s=default; b=G+2 WtLUr21Kze3yBaOmBSC4qykqAI3wp0MQ13kBaT7XZ4ZrRiJEsj3MQvxnjK59p7Vj aF3x4XZ5oBmGS6Un585DDi5KJuhoXzL1mW0r7eDYhpfzebFON5y+55Qf0A0Bc1R+ BIxSbMFXnn1js/9pJ0AItjlFezV8f9hi8rdWRcbY= 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-transfer-encoding; s=default; bh=HmKkhqOUi LNmCVI3YmBh/AoNcf8=; b=ZopQzBGj/C0ucxnkNHXDaqJCTwjIt2Pv4t+/lIjTN l0LaKJhV/llQPJPjJoIoCUUiq/hcAQV8ydrQzdVeKR9hgKu0YnE9Muad+fD1du4j ioG2aYSGe1k8EPiKS07h0VKGmcWfeMk7xfAzYagGWvnEYohemXiQw+QqPszCAjB0 3U= Received: (qmail 34635 invoked by alias); 12 Nov 2018 11:25:26 -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 34519 invoked by uid 89); 12 Nov 2018 11:25:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Claudiu, U*claziss, claudiu, Zissulescu X-HELO: mail-wm1-f46.google.com Received: from mail-wm1-f46.google.com (HELO mail-wm1-f46.google.com) (209.85.128.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Nov 2018 11:25:23 +0000 Received: by mail-wm1-f46.google.com with SMTP id v70-v6so7340663wmd.1 for ; Mon, 12 Nov 2018 03:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=0BJ7+kqHhkc75SxcJjGEmNCEMV9JAcRF5rO5SVMK9ws=; b=hX4FxxuD/Rh5OEBQ4VWwLfnzERsV+2djFK8Le4I8gaZExEPUlJaSLavTJNSShMZJf8 dLuo1kEgb2+YQi0hquyByKdqQCcHPmK2lMgFJMXQ3HHqrd6fzBf1VhQV9/Ip6mGDiFWo GZV0nw/E7q8QJlkir9ZH4XpIS2xFi4KbNFMD2mAg++E1GMGdZXuCUEDEg7yV2bJVB9bE 2OlgcN5ddXVDQw7P3V3enNQpEKXbbu0hhvGB72P9OBhyrzkTNy6DXo15rHQEHOal72vL 1mhoW3X3cNGe1TMAsQW2oXyLgG9BMHTZRbUE0hgG1ibRXdiV4D0giSQa+YLU+yDXeq7I 0JpA== Received: from localhost.localdomain ([86.120.4.133]) by smtp.gmail.com with ESMTPSA id g5-v6sm20317844wrw.97.2018.11.12.03.25.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 03:25:20 -0800 (PST) From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org Cc: fbedard@synopsys.com, andrew.burgess@embecosm.com, claziss@synopsys.com Subject: [PATCH 1/3] [ARC] Update EH code. Date: Mon, 12 Nov 2018 13:25:11 +0200 Message-Id: <20181112112513.4369-2-claziss@gmail.com> In-Reply-To: <20181112112513.4369-1-claziss@gmail.com> References: <20181112112513.4369-1-claziss@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes Our ABI says the blink is pushed first on stack followed by an unknown number of register saves, and finally by fp. Hence we cannot use the EH_RETURN_ADDRESS macro as the stack is not finalized at that moment. The alternative is to use the eh_return pattern and to initialize all the bits after register allocation when the stack layout is finalized. gcc/ xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.c (arc_eh_return_address_location): Repurpose it to fit the eh_return pattern. * config/arc/arc.md (eh_return): Define. (VUNSPEC_ARC_EH_RETURN): Likewise. * config/arc/arc-protos.h (arc_eh_return_address_location): Match new implementation. * config/arc/arc.h (EH_RETURN_HANDLER_RTX): Remove it. testsuite/ xxxx-xx-xx Claudiu Zissulescu * gcc.target/arc/builtin_eh.c: New test. --- gcc/config/arc/arc-protos.h | 2 +- gcc/config/arc/arc.c | 13 ++++++++----- gcc/config/arc/arc.h | 2 -- gcc/config/arc/arc.md | 15 +++++++++++++++ gcc/testsuite/gcc.target/arc/builtin_eh.c | 22 ++++++++++++++++++++++ 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arc/builtin_eh.c diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h index 6450b6a014e..4f72a06e3dc 100644 --- a/gcc/config/arc/arc-protos.h +++ b/gcc/config/arc/arc-protos.h @@ -110,7 +110,7 @@ extern bool arc_legitimize_reload_address (rtx *, machine_mode, int, int); extern void arc_secondary_reload_conv (rtx, rtx, rtx, bool); extern void arc_cpu_cpp_builtins (cpp_reader *); extern bool arc_store_addr_hazard_p (rtx_insn *, rtx_insn *); -extern rtx arc_eh_return_address_location (void); +extern void arc_eh_return_address_location (rtx); extern bool arc_is_jli_call_p (rtx); extern void arc_file_end (void); extern bool arc_is_secure_call_p (rtx); diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 6802ca66554..a92456b457d 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -3858,10 +3858,13 @@ arc_check_multi (rtx op, bool push_p) /* Return rtx for the location of the return address on the stack, suitable for use in __builtin_eh_return. The new return address will be written to this location in order to redirect the return to - the exception handler. */ + the exception handler. Our ABI says the blink is pushed first on + stack followed by an unknown number of register saves, and finally + by fp. Hence we cannot use the EH_RETURN_ADDRESS macro as the + stack is not finalized. */ -rtx -arc_eh_return_address_location (void) +void +arc_eh_return_address_location (rtx source) { rtx mem; int offset; @@ -3889,8 +3892,8 @@ arc_eh_return_address_location (void) remove this store seems perfectly sensible. Marking the memory address as volatile obviously has the effect of preventing DSE from removing the store. */ - MEM_VOLATILE_P (mem) = 1; - return mem; + MEM_VOLATILE_P (mem) = true; + emit_move_insn (mem, source); } /* PIC */ diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index afd6d7681cf..a0a84900917 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -1355,8 +1355,6 @@ do { \ #define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, 2) -#define EH_RETURN_HANDLER_RTX arc_eh_return_address_location () - /* Turn off splitting of long stabs. */ #define DBX_CONTIN_LENGTH 0 diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index a28c67ac184..a6bac0e8bee 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -163,6 +163,7 @@ VUNSPEC_ARC_SC VUNSPEC_ARC_LL VUNSPEC_ARC_BLOCKAGE + VUNSPEC_ARC_EH_RETURN ]) (define_constants @@ -6627,6 +6628,20 @@ core_3, archs4x, archs4xd, archs4xd_slow" [(set_attr "type" "call_no_delay_slot") (set_attr "length" "2")]) +;; Patterns for exception handling +(define_insn_and_split "eh_return" + [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] + VUNSPEC_ARC_EH_RETURN)] + "" + "#" + "reload_completed" + [(const_int 0)] + " + { + arc_eh_return_address_location (operands[0]); + DONE; + }" +) ;; include the arc-FPX instructions (include "fpx.md") diff --git a/gcc/testsuite/gcc.target/arc/builtin_eh.c b/gcc/testsuite/gcc.target/arc/builtin_eh.c new file mode 100644 index 00000000000..717a54bb084 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/builtin_eh.c @@ -0,0 +1,22 @@ +/* Check if we have the right offset for @bar function. */ +/* { dg-options "-O1" } */ + +void bar (void); + +void +foo (int x) +{ + __builtin_unwind_init (); + __builtin_eh_return (x, bar); +} + +/* { dg-final { scan-assembler "r24" } } */ +/* { dg-final { scan-assembler "r22" } } */ +/* { dg-final { scan-assembler "r20" } } */ +/* { dg-final { scan-assembler "r18" } } */ +/* { dg-final { scan-assembler "r16" } } */ +/* { dg-final { scan-assembler "r14" } } */ +/* { dg-final { scan-assembler "r13" } } */ +/* { dg-final { scan-assembler "r0" } } */ +/* { dg-final { scan-assembler "fp" } } */ +/* { dg-final { scan-assembler "fp,64" } } */ From patchwork Mon Nov 12 11:25:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu X-Patchwork-Id: 996352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489712-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rClPpQ5V"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="c2D4QKL/"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42tpNK53n6z9s1x for ; Mon, 12 Nov 2018 22:25:53 +1100 (AEDT) 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-transfer-encoding; q=dns; s=default; b=b3H NdbWT8OQmyY9hed3Hpf14ywH7G1uXVhBg7haNX4GPhTSgFpRGOlT8g8k3qR9p5xN fnmd2sT/aAJT+OgaoF9n+li+ZcfUYXFXPn2REkSB5a2mIEsljxvB7BsbWnI2mgTi JCAdxLHvnNP/WvuTc2E6SRHoRxa7Qm1tP/1fi5gg= 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-transfer-encoding; s=default; bh=7OO8awtm2 PMczRn0lIZcOErvbRk=; b=rClPpQ5VYhb8/Act7H+tYgEtWpifD/dxY2qbHAv0A n1P2Vjq/gn9/uYAKhtx5IdpdxVpMRl8wfe3FEr7pySMS68TrFhZtPP0mvJmpPs4o r3bdLv5oe/AGIyPHuaTpubFYTzEE6iq17IVLGc2gHEUfY0561RdYd8+yoxzW7Bqm 6U= Received: (qmail 34756 invoked by alias); 12 Nov 2018 11:25:26 -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 34636 invoked by uid 89); 12 Nov 2018 11:25:26 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=U*claziss, sk:claziss, HX-Received:sk:g6-v6mr, Hx-languages-length:1056 X-HELO: mail-wr1-f65.google.com Received: from mail-wr1-f65.google.com (HELO mail-wr1-f65.google.com) (209.85.221.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Nov 2018 11:25:24 +0000 Received: by mail-wr1-f65.google.com with SMTP id b13so8878367wrx.6 for ; Mon, 12 Nov 2018 03:25:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WqXB2QEjMhJSv58bQXAinNrBQIhc4QlVvoPZG8tPGHI=; b=c2D4QKL/p1M8JeHR442mbPqQeZpdXB8BJAM53Id/AzkCzBLgWRwoH6MSIjC+rFeQ75 1ELzorO/Hz7j0j/XOGRbw2RVFCBBWVEB2yodXDNPWTCcq/PQ2dJiOUH48+lJAMA5g1ex qZowPEm4POdFwr+xkSr35VhOSJonnVYtqbRfkfj+6mFER8QpfpNvf8omDOlsHOr4mAtH cKKzXP8p6T9QlqtD9kba++YKGHKUyAGGfjtTQonPJhAOtskngMffF7ZTaiM1W+0ugmJB 6wAC4T5FVwmHeutiVwQfepGFQcrqIF7PEucQlscptQk9lVKW1F6ZI3+VmEj8E87nuVw6 qcPg== Received: from localhost.localdomain ([86.120.4.133]) by smtp.gmail.com with ESMTPSA id g5-v6sm20317844wrw.97.2018.11.12.03.25.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 03:25:21 -0800 (PST) From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org Cc: fbedard@synopsys.com, andrew.burgess@embecosm.com, claziss@synopsys.com Subject: [PATCH 2/3] [ARC] Do not emit ZOL in the presence of text jump tables. Date: Mon, 12 Nov 2018 13:25:12 +0200 Message-Id: <20181112112513.4369-3-claziss@gmail.com> In-Reply-To: <20181112112513.4369-1-claziss@gmail.com> References: <20181112112513.4369-1-claziss@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes Avoid emitting lp instruction when in its ZOL body we find a jump table data in text section. gcc/ xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.c (hwloop_optimize): Bailout when detecting a jump table data in the text section. --- gcc/config/arc/arc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index a92456b457d..9eab4c27284 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -7791,7 +7791,17 @@ hwloop_optimize (hwloop_info loop) for (insn = loop->start_label; insn && insn != loop->loop_end; insn = NEXT_INSN (insn)) - length += NONDEBUG_INSN_P (insn) ? get_attr_length (insn) : 0; + { + length += NONDEBUG_INSN_P (insn) ? get_attr_length (insn) : 0; + if (JUMP_TABLES_IN_TEXT_SECTION + && JUMP_TABLE_DATA_P (insn)) + { + if (dump_file) + fprintf (dump_file, ";; loop %d has a jump table\n", + loop->loop_no); + return false; + } + } if (!insn) { From patchwork Mon Nov 12 11:25:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu X-Patchwork-Id: 996353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-489713-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TYCV7wb2"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VeCQE0l7"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42tpNX5Smnz9s6w for ; Mon, 12 Nov 2018 22:26:04 +1100 (AEDT) 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-transfer-encoding; q=dns; s=default; b=YfP aBZMJL3NjjDjA0knx7gyca8GQd+e5StiQBh0HTeV0pS6M/+8BfGwgLIOgmXF9Mjs xvKWHf11GfMm/Dcdy7syzxwHa5bRPkcFAnIsxhJGbhsyQUcxdE4hWPWK8gE3Nclh 7ekkRoqglazJadCL9qyuhHbJT0cF3IrQCP7II+Ig= 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-transfer-encoding; s=default; bh=c0EQzvZF7 XHgEHw3zgdEdNfvf6Y=; b=TYCV7wb28cm6X2vxvA4Zead8LPjAibLI6tpjQM4B/ lIK8V1olVdDP1xqbvQ2gmulAkK11FS6sqTLEt7Czb9n7ypCGn/FknwLzO9d+YYK2 4q2EY1ghYzVzJsw9yRyX+qbFd8I6a2Pj24R3LjReW10p9AnHK/iNAMBM9NG129iT sw= Received: (qmail 35007 invoked by alias); 12 Nov 2018 11:25:28 -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 34903 invoked by uid 89); 12 Nov 2018 11:25:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail-wr1-f66.google.com Received: from mail-wr1-f66.google.com (HELO mail-wr1-f66.google.com) (209.85.221.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Nov 2018 11:25:25 +0000 Received: by mail-wr1-f66.google.com with SMTP id j17-v6so8869571wrq.11 for ; Mon, 12 Nov 2018 03:25:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=afFk0e8uDlm76oqa812gdAsep9fhkNQu+QcKrQLxVVk=; b=VeCQE0l73cdhehYhsPova22F57jVnfJTQKw1rYyqd4wlPPAjocGkzblvvYgxJif+d3 x8CoXBIkdo7b2agLqKpO8nukyaXboPTtpAJPcvuwf7hPhOR3d9IuHsXGnvIWgJ3UNMgT JH9cz6Y0tAenS+VbU8CwXeqXZGSD85CESU5cjpzWTFDDcYJFGF75gAG8+XDzNYlAc8O1 G1VINijTAgmQXkew1wMBJu5rRLM6PtOQ/aA7TmId0ezs12p4Mx7XMOAfAOUszsRKngWh d/bdB/onte6dkvmTtUpRQzbylgPPJI7F9+D5nz6qeTEuQf7WCr2HoPxmcJ5+nm4aNt42 UnJg== Received: from localhost.localdomain ([86.120.4.133]) by smtp.gmail.com with ESMTPSA id g5-v6sm20317844wrw.97.2018.11.12.03.25.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 03:25:23 -0800 (PST) From: Claudiu Zissulescu To: gcc-patches@gcc.gnu.org Cc: fbedard@synopsys.com, andrew.burgess@embecosm.com, claziss@synopsys.com Subject: [PATCH 3/3] [ARC] Add support for profiling in glibc. Date: Mon, 12 Nov 2018 13:25:13 +0200 Message-Id: <20181112112513.4369-4-claziss@gmail.com> In-Reply-To: <20181112112513.4369-1-claziss@gmail.com> References: <20181112112513.4369-1-claziss@gmail.com> MIME-Version: 1.0 X-IsSubscribed: yes Use PROFILE_HOOK to add mcount library calls in each toolchain. gcc/ xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.h (FUNCTION_PROFILER): Redefine to empty. * config/arc/elf.h (PROFILE_HOOK): Define. * config/arc/linux.h (PROFILE_HOOK): Likewise. --- gcc/config/arc/arc.h | 12 +++--------- gcc/config/arc/elf.h | 9 +++++++++ gcc/config/arc/linux.h | 10 ++++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index a0a84900917..f75c273691c 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -775,15 +775,9 @@ extern int arc_initial_elimination_offset(int from, int to); #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ (OFFSET) = arc_initial_elimination_offset ((FROM), (TO)) -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. */ -#define FUNCTION_PROFILER(FILE, LABELNO) \ - do { \ - if (flag_pic) \ - fprintf (FILE, "\tbl\t__mcount@plt\n"); \ - else \ - fprintf (FILE, "\tbl\t__mcount\n"); \ - } while (0) +/* All the work done in PROFILE_HOOK, but still required. */ +#undef FUNCTION_PROFILER +#define FUNCTION_PROFILER(STREAM, LABELNO) do { } while (0) #define NO_PROFILE_COUNTERS 1 diff --git a/gcc/config/arc/elf.h b/gcc/config/arc/elf.h index 3472fd2e418..3aabcf8c9e6 100644 --- a/gcc/config/arc/elf.h +++ b/gcc/config/arc/elf.h @@ -78,3 +78,12 @@ along with GCC; see the file COPYING3. If not see #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ "--start-group %G %{!specs=*:%{!nolibc:-lc -lnosys}} --end-group" + +/* Emit rtl for profiling. Output assembler code to FILE + to call "_mcount" for profiling a function entry. */ +#define PROFILE_HOOK(LABEL) \ + { \ + rtx fun; \ + fun = gen_rtx_SYMBOL_REF (Pmode, "__mcount"); \ + emit_library_call (fun, LCT_NORMAL, VOIDmode); \ + } diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h index 62ebe4de0fc..993f445d2a0 100644 --- a/gcc/config/arc/linux.h +++ b/gcc/config/arc/linux.h @@ -123,3 +123,13 @@ along with GCC; see the file COPYING3. If not see : "=r" (_beg) \ : "0" (_beg), "r" (_end), "r" (_xtr), "r" (_scno)); \ } + +/* Emit rtl for profiling. Output assembler code to FILE + to call "_mcount" for profiling a function entry. */ +#define PROFILE_HOOK(LABEL) \ + { \ + rtx fun, rt; \ + rt = get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); \ + fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); \ + emit_library_call (fun, LCT_NORMAL, VOIDmode, rt, Pmode); \ + }