From patchwork Tue Aug 1 11:07:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 796174 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-459497-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="asWYzbZv"; 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 3xMD764jyMz9tWh for ; Tue, 1 Aug 2017 21:07:30 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=igiJSRNQDwo5iWFtIgUQordh1sSpi2NN70MbCiRHpKwAJx yFjhPZULhCzcsXp32i6vx1yQgKrwaNeb+pOyRukZO6O/8c1+kQM4h7brkPkY4IA8 2Tv30y3D2L3omviRAhinJgQZcrv25sGMVzsw5b5CLaxvtXY24QYBFTdpMJYCI= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=sxpGUf4/sE4nhfpSCVS++HMcVeQ=; b=asWYzbZvCWIixK10pdfU GTwstt2ctH3SzPudZJqZ/cTHxD9yHownRjeJsbRb2p0YOYtiEPS84G513H2ma4/k sBTSoLuQqdnjd6eD59lMv3hF/dJft6Iz0CNEzfiyi2TBc1uXc8pUuQpvLaXhq+dU JRdEIf01rNkaDT0lk1fui3A= Received: (qmail 57941 invoked by alias); 1 Aug 2017 11:07:21 -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 57907 invoked by uid 89); 1 Aug 2017 11:07:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1939, hello! X-HELO: mail-ua0-f177.google.com Received: from mail-ua0-f177.google.com (HELO mail-ua0-f177.google.com) (209.85.217.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 01 Aug 2017 11:07:19 +0000 Received: by mail-ua0-f177.google.com with SMTP id d29so5360042uai.2 for ; Tue, 01 Aug 2017 04:07:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=gQ/zuav21QYjnesSNSND/0lJV4rMFuXPWRJtDXlYC5I=; b=KxovXiE1ZVZO+au3b4xG64FZWIUH8eqmZxzJHSpK6zaLHYNf/oHsD4Iroa2TZe4LkZ KzbT6sBatc/ekB0F+ns94YjpsIa9Q1729EnLpdB1MgFra+aQGlV/nSBeG394PsR/j1mo p9bq6RWlPG5M9jTE7Fno6LtMzpX3TGLyelIkdzPV1WwK5wsg2+whmqDafIEGKPTWOGiq wC7dQ+HzroqbMA4/SyVB1fUWkx/pZqlI7Tg5tmzE6jtSNwQGDr/JnJDXXcuvZ9bOQQcs ae6/vtKtAFmgNo2skfXDq7yFOa7fKXYa6bvykKdUrzZKSatlsTenIEroyRHsHGbnVJQ3 3bQg== X-Gm-Message-State: AIVw1129yvVfjeMKm837CrSN6glAC9Uv+xDylq0Z96whFwx26uOClgbj r9onD7R6UwSQVfOaIf8U0g7SmtHRkw== X-Received: by 10.176.4.111 with SMTP id 102mr14746164uav.146.1501585637540; Tue, 01 Aug 2017 04:07:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.68.218 with HTTP; Tue, 1 Aug 2017 04:07:16 -0700 (PDT) From: Uros Bizjak Date: Tue, 1 Aug 2017 13:07:16 +0200 Message-ID: Subject: [PATCH, i386]: Fix PR81639, ICE in rtl_verify_bb_insns with a naked function To: "gcc-patches@gcc.gnu.org" Hello! Naked functions should not sibcall, since in naked functions epilogue point (placed just above sibcal insn) is unreachable and marked with a trap insn. 2017-08-01 Uros Bizjak PR target/81639 * config/i386/i386.c (ix86_funciton_naked): New prototype. (ix86_function_ok_for_sibcall): Return false for naked functions. testsuite/ChangeLog: 2017-08-01 Uros Bizjak PR target/81639 * gcc.target/i386/pr81639.c: New test. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Committed to mainline. Uros. Index: config/i386/i386.c =================================================================== --- config/i386/i386.c (revision 250758) +++ config/i386/i386.c (working copy) @@ -94,6 +94,7 @@ static rtx legitimize_pe_coff_extern_decl (rtx, bo static rtx legitimize_pe_coff_symbol (rtx, bool); static void ix86_print_operand_address_as (FILE *, rtx, addr_space_t, bool); static bool ix86_save_reg (unsigned int, bool, bool); +static bool ix86_function_naked (const_tree); #ifndef CHECK_STACK_LIMIT #define CHECK_STACK_LIMIT (-1) @@ -7929,6 +7930,9 @@ ix86_function_ok_for_sibcall (tree decl, tree exp) rtx a, b; bool bind_global = decl && !targetm.binds_local_p (decl); + if (ix86_function_naked (current_function_decl)) + return false; + /* Sibling call isn't OK if there are no caller-saved registers since all registers must be preserved before return. */ if (cfun->machine->no_caller_saved_registers) Index: testsuite/gcc.target/i386/pr81639.c =================================================================== --- testsuite/gcc.target/i386/pr81639.c (nonexistent) +++ testsuite/gcc.target/i386/pr81639.c (working copy) @@ -0,0 +1,12 @@ +/* PR target/81639 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void b (void); + +void +__attribute__ ((naked)) +a (void) +{ + b (); +}