{"id":808657,"url":"http://patchwork.ozlabs.org/api/patches/808657/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/patch/20170901114251.GH2323@tucnak/","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170901114251.GH2323@tucnak>","list_archive_url":null,"date":"2017-09-01T11:42:51","name":"Fix x86_64 ICE with -fpie -mcmodel=large (PR target/81766)","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"28a98a29fc837fb0cd9d6a3d59d7a23aa78a1bc1","submitter":{"id":671,"url":"http://patchwork.ozlabs.org/api/people/671/?format=json","name":"Jakub Jelinek","email":"jakub@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20170901114251.GH2323@tucnak/mbox/","series":[{"id":1010,"url":"http://patchwork.ozlabs.org/api/series/1010/?format=json","web_url":"http://patchwork.ozlabs.org/project/gcc/list/?series=1010","date":"2017-09-01T11:42:51","name":"Fix x86_64 ICE with -fpie -mcmodel=large (PR target/81766)","version":1,"mbox":"http://patchwork.ozlabs.org/series/1010/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808657/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808657/checks/","tags":{},"related":[],"headers":{"Return-Path":"<gcc-patches-return-461266-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461266-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"ib6a3oiJ\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jakub@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkHRt371Cz9sRV\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 21:43:05 +1000 (AEST)","(qmail 38962 invoked by alias); 1 Sep 2017 11:42:58 -0000","(qmail 38953 invoked by uid 89); 1 Sep 2017 11:42:58 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tFri, 01 Sep 2017 11:42:56 +0000","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.14])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id A11C281E0C;\n\tFri,  1 Sep 2017 11:42:55 +0000 (UTC)","from tucnak.zalov.cz (ovpn-116-33.ams2.redhat.com\n\t[10.36.116.33])\tby smtp.corp.redhat.com (Postfix) with ESMTPS\n\tid 385A97B0C0; Fri,  1 Sep 2017 11:42:55 +0000 (UTC)","from tucnak.zalov.cz (localhost [127.0.0.1])\tby tucnak.zalov.cz\n\t(8.15.2/8.15.2) with ESMTP id v81Bgqfh007440;\n\tFri, 1 Sep 2017 13:42:53 +0200","(from jakub@localhost)\tby tucnak.zalov.cz (8.15.2/8.15.2/Submit)\n\tid v81BgpoM007439; Fri, 1 Sep 2017 13:42:51 +0200"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:reply-to:mime-version\n\t:content-type; q=dns; s=default; b=oJXReqfd8ssMDD+CvsPcCz9Xk66/J\n\tI86WWurGutlc8/AdxAlEE8beakV8V4WIXC5w7tbfx3TtEW2Rq0fGsFJdSyQ5znlR\n\tF4ewf7+8bSRMivlBh/lo+dYjwRBjediHl7fdGkUoS3YryS1wvQ5sLmW03z0tkcxP\n\tpPj9d5+fO6/WpA=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:reply-to:mime-version\n\t:content-type; s=default; bh=xaD1Lv7KO839gEAodG+wfwG81YA=; b=ib6\n\ta3oiJ2VTRma2Ecs4eMoqi/xspRnDCFDP1rZRI4RVKWVvTSCIkgnE2z3qgmEbw9BJ\n\tNJGHeiqAgNoLdcoI2aFUcouZPLQR6jy+ybr6wMKDW7jv/Fg0lvgdvNMDorGt8CvR\n\tJSo6zYelpNtS3Bg/fMYZhmZe1ErQ2LVg3juOoJz4=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2,\n\tGIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=wrapping","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com A11C281E0C","Date":"Fri, 1 Sep 2017 13:42:51 +0200","From":"Jakub Jelinek <jakub@redhat.com>","To":"Uros Bizjak <ubizjak@gmail.com>","Cc":"gcc-patches@gcc.gnu.org","Subject":"[PATCH] Fix x86_64 ICE with -fpie -mcmodel=large (PR target/81766)","Message-ID":"<20170901114251.GH2323@tucnak>","Reply-To":"Jakub Jelinek <jakub@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","User-Agent":"Mutt/1.7.1 (2016-10-04)","X-IsSubscribed":"yes"},"content":"Hi!\n\nAs mentioned in the PR, ix86_init_pic_reg for -mcmodel=large PIC creates\ninvalid RTL.  Shrink wrapping managed to work around it by unconditionally\nrunning find_many_sub_basic_blocks that has been invoked even when the\nprologue or split prologue actually didn't contain anything, but that isn't\ndone anymore.\n\nThe problem is that we add a label into the sequence that we then insert on\nthe single succ edge after ENTRY; but this insertion inserts the label after\nthe NOTE_INSN_BLOCK_BEG, which is invalid, because labels should precede\nthat.\n\nFixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for\ntrunk?\n\n2017-09-01  Jakub Jelinek  <jakub@redhat.com>\n\n\tPR target/81766\n\t* config/i386/i386.c (ix86_init_large_pic_reg): Return label instead of void.\n\t(ix86_init_pic_reg): Remember label from ix86_init_large_pic_reg, if non-NULL\n\tand preceded by NOTE_INSN_BASIC_BLOCK, swap the note and label.\n\n\t* gcc.target/i386/pr81766.c: New test.\n\n\n\tJakub","diff":"--- gcc/config/i386/i386.c.jj\t2017-08-07 18:50:10.000000000 +0200\n+++ gcc/config/i386/i386.c\t2017-08-08 16:01:41.917136120 +0200\n@@ -8829,7 +8829,7 @@ ix86_use_pseudo_pic_reg (void)\n \n /* Initialize large model PIC register.  */\n \n-static void\n+static rtx_code_label *\n ix86_init_large_pic_reg (unsigned int tmp_regno)\n {\n   rtx_code_label *label;\n@@ -8846,6 +8846,7 @@ ix86_init_large_pic_reg (unsigned int tm\n   emit_insn (gen_set_got_offset_rex64 (tmp_reg, label));\n   emit_insn (ix86_gen_add3 (pic_offset_table_rtx,\n \t\t\t    pic_offset_table_rtx, tmp_reg));\n+  return label;\n }\n \n /* Create and initialize PIC register if required.  */\n@@ -8854,6 +8855,7 @@ ix86_init_pic_reg (void)\n {\n   edge entry_edge;\n   rtx_insn *seq;\n+  rtx_code_label *label = NULL;\n \n   if (!ix86_use_pseudo_pic_reg ())\n     return;\n@@ -8863,7 +8865,7 @@ ix86_init_pic_reg (void)\n   if (TARGET_64BIT)\n     {\n       if (ix86_cmodel == CM_LARGE_PIC)\n-\tix86_init_large_pic_reg (R11_REG);\n+\tlabel = ix86_init_large_pic_reg (R11_REG);\n       else\n \temit_insn (gen_set_got_rex64 (pic_offset_table_rtx));\n     }\n@@ -8887,6 +8889,22 @@ ix86_init_pic_reg (void)\n   entry_edge = single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun));\n   insert_insn_on_edge (seq, entry_edge);\n   commit_one_edge_insertion (entry_edge);\n+\n+  if (label)\n+    {\n+      basic_block bb = BLOCK_FOR_INSN (label);\n+      rtx_insn *bb_note = PREV_INSN (label);\n+      /* If the note preceding the label starts a basic block, and the\n+\t label is a member of the same basic block, interchange the two.  */\n+      if (bb_note != NULL_RTX\n+\t  && NOTE_INSN_BASIC_BLOCK_P (bb_note)\n+\t  && bb != NULL\n+\t  && bb == BLOCK_FOR_INSN (bb_note))\n+\t{\n+\t  reorder_insns_nobb (bb_note, bb_note, label);\n+\t  BB_HEAD (bb) = label;\n+\t}\n+    }\n }\n \n /* Initialize a variable CUM of type CUMULATIVE_ARGS\n--- gcc/testsuite/gcc.target/i386/pr81766.c.jj\t2017-08-08 16:10:04.299459808 +0200\n+++ gcc/testsuite/gcc.target/i386/pr81766.c\t2017-08-08 16:09:28.000000000 +0200\n@@ -0,0 +1,9 @@\n+/* PR target/81766 */\n+/* { dg-do compile { target { pie && lp64 } } } */\n+/* { dg-options \"-O2 -fpie -mcmodel=large\" } */\n+\n+int\n+main ()\n+{\n+  return 0;\n+}\n","prefixes":[]}