From patchwork Fri Nov 14 17:10:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radovan Obradovic X-Patchwork-Id: 410942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 C04551400F1 for ; Sat, 15 Nov 2014 04:11:10 +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:references:in-reply-to :content-type:content-transfer-encoding:mime-version; q=dns; s= default; b=RTnc2nmt5XU8+OtoO3ilqIKnHLvAsalOZttqjHN3vFjtcYnJRoBkG 1t+cxY9KAq4vwSi8ZtR2RRFCjXJXVuGv7G4l+fpBFPBIHZHVzIt1Kq/LMbDTPMC4 RATrIQs0v0BNsShlXd3fw+aLyvn/MfQDbGZ8vS8sZQeSwRIaHTAUYI= 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:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=default; bh=ch5+lKODKqToHmX1ico4IomZHS0=; b=ovdzQUoEIhs974xZSKCvYlnZAMKk s2FckhsELYpGNVIbXMlkYRafHiIOwSX9LkIAPGxBj1hpgHxNULoJUlAimJL8Ik5k eSNqyWbkDSN6mrctGq4/+0usAiknD1A2sRpRGoM6mfSJevvTkTyRtw4EFtACumEG Z7TRuwaCBtsUi/Y= Received: (qmail 29558 invoked by alias); 14 Nov 2014 17:11:02 -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 29548 invoked by uid 89); 14 Nov 2014 17:11:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mailapp01.imgtec.com Received: from mailapp01.imgtec.com (HELO mailapp01.imgtec.com) (195.59.15.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Nov 2014 17:11:01 +0000 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id B500B1BAC4E09; Fri, 14 Nov 2014 17:10:55 +0000 (GMT) Received: from KLMAIL02.kl.imgtec.org (10.40.60.222) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 14 Nov 2014 17:10:58 +0000 Received: from BAMAIL02.ba.imgtec.org (10.20.40.28) by klmail02.kl.imgtec.org (10.40.60.222) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 14 Nov 2014 17:10:58 +0000 Received: from BADAG02.ba.imgtec.org ([fe80::612d:e977:c603:32d6]) by bamail02.ba.imgtec.org ([::1]) with mapi id 14.03.0174.001; Fri, 14 Nov 2014 09:10:55 -0800 From: Radovan Obradovic To: Jeff Law , "gcc-patches@gcc.gnu.org" CC: Petar Jovanovic Subject: RE: [PATCH] Disable -fuse-caller-save when -pg is active Date: Fri, 14 Nov 2014 17:10:55 +0000 Message-ID: References: , <5464E8A8.9060902@redhat.com> In-Reply-To: <5464E8A8.9060902@redhat.com> MIME-Version: 1.0 Thank you for the quick reply. > Please repost after updating to test HAVE_prologue and HAVE_epilogue and > adding a testcase. I have managed to reproduce the problem on the small test case on mips32, but the test is architecture independent and should probably fail on many other ports without this patch. The optimization is also disabled if macros HAVE_prologue and HAVE_epilogue are not defined or have false value. Radovan Patch - diff --git a/gcc/testsuite/gcc.dg/aru-2.c b/gcc/testsuite/gcc.dg/aru-2.c new file mode 100644 index 0000000..624bd7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/aru-2.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -pg" } */ + +static int __attribute__((noinline)) +bar (int x) +{ + return x + 3; +} + +int __attribute__((noinline)) +foo (int y0, int y1, int y2, int y3, int y4) +{ + int r = 0; + r += bar (r + y4); + r += bar (r + y3); + r += bar (r + y2); + r += bar (r + y1); + r += bar (r + y0); + return r; +} + +int +main (void) +{ + int z = foo (0, 1, 2, 3, 4); + return !(z == 191); +} diff --git a/gcc/toplev.c b/gcc/toplev.c index eb37bfe..ddaf8e0 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -111,6 +111,13 @@ along with GCC; see the file COPYING3. If not see declarations for e.g. AIX 4.x. */ #endif +#ifndef HAVE_epilogue +#define HAVE_epilogue 0 +#endif +#ifndef HAVE_prologue +#define HAVE_prologue 0 +#endif + #include static void general_init (const char *); @@ -1605,6 +1612,11 @@ process_options (void) /* Save the current optimization options. */ optimization_default_node = build_optimization_node (&global_options); optimization_current_node = optimization_default_node; + + /* Disable use caller save optimization if profiler is active or port + does not emit prologue and epilogue as RTL. */ + if (profile_flag || !HAVE_prologue || !HAVE_epilogue) + flag_use_caller_save = 0; } /* This function can be called multiple times to reinitialize the compiler