From patchwork Wed Jan 15 21:43:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 311277 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 564502C0097 for ; Thu, 16 Jan 2014 08:43:30 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=g+kHXKZWfYbZ6rLsw StH1FPJKwdQY3SaDRl5Ba5Ltojp6j7JN6JktKTigniMsqg09OlbM/ALNqjcyXiZA TmmiOUSoRok2YG63dlAAL7+hOTS/fKiOhozK4aNUGtgxuB0faIBvbxIKA89O+mY5 E1bNpgzYDqnmIZGWVOVb5zJB0k= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=TD7LC10APSm/Ri36P7EGDGo dvwk=; b=OINm6Ecyb6gQ71UDeLt/Ut7BExMwN9kcv4wHJ3JJ5eGEtXQGNpzHQYi E/LxFP5HnVkgvfJj+HqClk2peTC/6No/KRvMSYGBiN1eqDta9kFo3e2Yk9qkktq9 41DMNH/jpI7z424c8n/Awm9X3msY2AN7vBA9RsXukuC/NaTk94Qs= Received: (qmail 9761 invoked by alias); 15 Jan 2014 21:43:23 -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 9748 invoked by uid 89); 15 Jan 2014 21:43:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Jan 2014 21:43:22 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0FLhKdV031703 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 15 Jan 2014 16:43:20 -0500 Received: from pebble.twiddle.net (vpn-232-63.phx2.redhat.com [10.3.232.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s0FLhJsu022204; Wed, 15 Jan 2014 16:43:20 -0500 Message-ID: <52D700F6.2060609@redhat.com> Date: Wed, 15 Jan 2014 13:43:18 -0800 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: "H.J. Lu" CC: GCC Patches Subject: Re: [PATCH] Diagnose pr54694 References: <52D6B611.6040802@redhat.com> In-Reply-To: X-IsSubscribed: yes On 01/15/2014 08:37 AM, H.J. Lu wrote: > We should add a testcase to verify this. > I included the following testcase with the commit. I couldn't find a way to test this properly generically, so I just went with the obvious i386 test. r~ diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c93bf23..075582a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2014-01-15 Richard Henderson + + PR debug/54694 + * reginfo.c (global_regs_decl): Globalize. + * rtl.h (global_regs_decl): Declare. + * ira.c (do_reload): Diagnose frame_pointer_needed and it + reserved via global_regs. + 2014-01-15 Teresa Johnson * tree-ssa-sccvn.c (visit_reference_op_call): Handle NULL vdef. diff --git a/gcc/ira.c b/gcc/ira.c index 41e05f4..ee6010a 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -5532,6 +5532,18 @@ do_reload (void) if (need_dce && optimize) run_fast_dce (); + /* Diagnose uses of the hard frame pointer when it is used as a global + register. Often we can get away with letting the user appropriate + the frame pointer, but we should let them know when code generation + makes that impossible. */ + if (global_regs[HARD_FRAME_POINTER_REGNUM] && frame_pointer_needed) + { + tree decl = global_regs_decl[HARD_FRAME_POINTER_REGNUM]; + error_at (DECL_SOURCE_LOCATION (current_function_decl), + "frame pointer required, but reserved"); + inform (DECL_SOURCE_LOCATION (decl), "for %qD", decl); + } + timevar_pop (TV_IRA); } diff --git a/gcc/reginfo.c b/gcc/reginfo.c index efaa0cb..bdb980d 100644 --- a/gcc/reginfo.c +++ b/gcc/reginfo.c @@ -86,7 +86,7 @@ static const char initial_call_really_used_regs[] = CALL_REALLY_USED_REGISTERS; char global_regs[FIRST_PSEUDO_REGISTER]; /* Declaration for the global register. */ -static tree GTY(()) global_regs_decl[FIRST_PSEUDO_REGISTER]; +tree global_regs_decl[FIRST_PSEUDO_REGISTER]; /* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used in dataflow more conveniently. */ diff --git a/gcc/rtl.h b/gcc/rtl.h index e7d60ee..10ee818 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2795,6 +2795,8 @@ extern void _fatal_insn (const char *, const_rtx, const char *, int, const char #define fatal_insn_not_found(insn) \ _fatal_insn_not_found (insn, __FILE__, __LINE__, __FUNCTION__) +/* reginfo.c */ +extern tree GTY(()) global_regs_decl[FIRST_PSEUDO_REGISTER]; #endif /* ! GCC_RTL_H */ diff --git a/gcc/testsuite/gcc.target/i386/pr54694.c b/gcc/testsuite/gcc.target/i386/pr54694.c new file mode 100644 index 0000000..bcf82c2 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr54694.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +register void *hfp __asm__("%ebp"); /* { dg-message "note: for" } */ + +extern void g(void *); + +void f(int x) /* { dg-error "frame pointer required" } */ +{ + g(__builtin_alloca(x)); +}