From patchwork Mon Jan 3 12:04:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 77246 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]) by ozlabs.org (Postfix) with SMTP id D786AB6F1E for ; Mon, 3 Jan 2011 23:06:56 +1100 (EST) Received: (qmail 30167 invoked by alias); 3 Jan 2011 12:06:52 -0000 Received: (qmail 30158 invoked by uid 22791); 3 Jan 2011 12:06:51 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 03 Jan 2011 12:06:45 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id B6BA7CB021D for ; Mon, 3 Jan 2011 13:06:42 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5UPy9gWqh4po for ; Mon, 3 Jan 2011 13:06:42 +0100 (CET) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 9B1BACB01BA for ; Mon, 3 Jan 2011 13:06:41 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [SPARC] Backport a couple of fixes to 4.5 branch Date: Mon, 3 Jan 2011 13:04:25 +0100 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201101031304.25921.ebotcazou@adacore.com> 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 They are related to the -freorder-* family of switches; applied on the branch. 2011-01-03 Eric Botcazou Backport from mainline 2010-12-30 Eric Botcazou PR target/47038 * config/sparc/sparc.c (sparc_file_end): Call resolve_unique_section on the GOT helper if USE_HIDDEN_LINKONCE. 2010-12-02 Eric Botcazou PR target/46685 * config/sparc/sparc.c (can_use_mov_pic_label_ref): New predicate. (sparc_expand_move): Call it to decide whether to emit the special mov{si,di}_pic_label_ref patterns. (sparc_legitimize_pic_address): Call it to decide whether to emit the regular PIC sequence for labels. Fix long line. (sparc_file_end): Set is_thunk for the PIC helper. Index: config/sparc/sparc.c =================================================================== --- config/sparc/sparc.c (revision 168407) +++ config/sparc/sparc.c (working copy) @@ -966,6 +966,36 @@ fp_high_losum_p (rtx op) return 0; } +/* Return true if the address of LABEL can be loaded by means of the + mov{si,di}_pic_label_ref patterns in PIC mode. */ + +static bool +can_use_mov_pic_label_ref (rtx label) +{ + /* VxWorks does not impose a fixed gap between segments; the run-time + gap can be different from the object-file gap. We therefore can't + assume X - _GLOBAL_OFFSET_TABLE_ is a link-time constant unless we + are absolutely sure that X is in the same segment as the GOT. + Unfortunately, the flexibility of linker scripts means that we + can't be sure of that in general, so assume that GOT-relative + accesses are never valid on VxWorks. */ + if (TARGET_VXWORKS_RTP) + return false; + + /* Similarly, if the label is non-local, it might end up being placed + in a different section than the current one; now mov_pic_label_ref + requires the label and the code to be in the same section. */ + if (LABEL_REF_NONLOCAL_P (label)) + return false; + + /* Finally, if we are reordering basic blocks and partition into hot + and cold sections, this might happen for any label. */ + if (flag_reorder_blocks_and_partition) + return false; + + return true; +} + /* Expand a move instruction. Return true if all work is done. */ bool @@ -1000,14 +1030,9 @@ sparc_expand_move (enum machine_mode mod if (pic_address_needs_scratch (operands[1])) operands[1] = legitimize_pic_address (operands[1], NULL_RTX); - /* VxWorks does not impose a fixed gap between segments; the run-time - gap can be different from the object-file gap. We therefore can't - assume X - _GLOBAL_OFFSET_TABLE_ is a link-time constant unless we - are absolutely sure that X is in the same segment as the GOT. - Unfortunately, the flexibility of linker scripts means that we - can't be sure of that in general, so assume that _G_O_T_-relative - accesses are never valid on VxWorks. */ - if (GET_CODE (operands[1]) == LABEL_REF && !TARGET_VXWORKS_RTP) + /* We cannot use the mov{si,di}_pic_label_ref patterns in all cases. */ + if (GET_CODE (operands[1]) == LABEL_REF + && can_use_mov_pic_label_ref (operands[1])) { if (mode == SImode) { @@ -3389,7 +3414,7 @@ legitimize_pic_address (rtx orig, rtx re if (GET_CODE (orig) == SYMBOL_REF /* See the comment in sparc_expand_move. */ - || (TARGET_VXWORKS_RTP && GET_CODE (orig) == LABEL_REF)) + || (GET_CODE (orig) == LABEL_REF && !can_use_mov_pic_label_ref (orig))) { rtx pic_ref, address; rtx insn; @@ -3440,11 +3465,13 @@ legitimize_pic_address (rtx orig, rtx re } else { - pic_ref = gen_const_mem (Pmode, - gen_rtx_PLUS (Pmode, - pic_offset_table_rtx, address)); + pic_ref + = gen_const_mem (Pmode, + gen_rtx_PLUS (Pmode, + pic_offset_table_rtx, address)); insn = emit_move_insn (reg, pic_ref); } + /* Put a REG_EQUAL note on this insn, so that it can be optimized by loop. */ set_unique_reg_note (insn, REG_EQUAL, orig); @@ -3482,9 +3509,8 @@ legitimize_pic_address (rtx orig, rtx re return gen_rtx_PLUS (Pmode, base, offset); } else if (GET_CODE (orig) == LABEL_REF) - /* ??? Why do we do this? */ - /* Now movsi_pic_label_ref uses it, but we ought to be checking that - the register is live instead, in case it is eliminated. */ + /* ??? We ought to be checking that the register is live instead, in case + it is eliminated. */ crtl->uses_pic_offset_table = 1; return orig; @@ -9082,7 +9108,9 @@ sparc_file_end (void) make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; DECL_VISIBILITY_SPECIFIED (decl) = 1; + resolve_unique_section (decl, 0, flag_function_sections); allocate_struct_function (decl, true); + cfun->is_thunk = 1; current_function_decl = decl; init_varasm_status (); assemble_start_function (decl, name);