From patchwork Wed Oct 5 12:12:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Clarke X-Patchwork-Id: 678416 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 3spvnB0HZBz9s3v for ; Wed, 5 Oct 2016 23:13:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=bxukFGWu; dkim-atps=neutral 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; q=dns; s=default; b=ybyEPTvuGxp7 261RI+oAnBvl1DuwW2v0thY627JjKRaBexKeCBVEneLOapOW4y7S3H4nBZ/maAYA QpkbgFOzvXRTgHhg2SvRn9VuqEKIPwERCatfEXUp2Pe2HGgVia+WZeQCp0VmnsgB i/gpGfGWsMQlvq5GQVc4AP5xojOCYoE= 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; s=default; bh=Vdvl+Nh5xcb/DFO8Il sRhk91600=; b=bxukFGWuo5aLPhfJjfDGwcXrpd4Dgs6HdvPePPTP1kw3wonGSh LALYcEZiIvJaZiMHhbOAWmdKlLvKemKaRszDmuzApVjjOK9rG5pQxCFpOff2TUtL Xzf0SWZ9/+nTUvH0V4itToTIPN+L2uQ063x8Xjfo8MxeQ/F/CAA54JlcI= Received: (qmail 21853 invoked by alias); 5 Oct 2016 12:12:53 -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 21812 invoked by uid 89); 5 Oct 2016 12:12:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=RECORD_TYPE, record_type, iced, eligible X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Oct 2016 12:12:42 +0000 Received: by mail-wm0-f52.google.com with SMTP id f193so225357472wmg.0 for ; Wed, 05 Oct 2016 05:12:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=T/r7xQ43xuOgcdumnrmYAxRvg/sNZwXCRdaodggKotA=; b=ZH6zn95hAK5qEZj33sb+xGOG1wrJO06CzCIbS8dyIdE5awBctmAwDj3MToPjLsYXoJ z2OXPKWY7S7j6zCr7gRIGdR19p5zWsvvAV1rA/62FhS8fnyUyG8iQkPfd69suXDSERqh Se/1ieoUOApwd1dW8ARqjcrZvib7QEjFkqmMw0sCN7iuto5t4zfqgHHW1Jwd4jtTS2IM InZevHSNSTJfHfES02LiWx47lNhuF/6IpxSjy/myV5MgLv5Zbg5q9L++MrZyXqsAo/cm iESZ69Z6PU2Mr/nSAlXE8yR+SIl0408Thhi4o/7gGX2mVSvMsgorQ8S/AYV3KpnXzbxI YspA== X-Gm-Message-State: AA6/9RnzNboAGZYn9dHEMGRrIQllvKcGD3BO3oms5zNfvq3Q8pT1FId3cy+56cPCArcm7/7h X-Received: by 10.194.30.137 with SMTP id s9mr4950830wjh.77.1475669560286; Wed, 05 Oct 2016 05:12:40 -0700 (PDT) Received: from Jamess-MacBook.local (global-184-8.nat-1.net.cam.ac.uk. [131.111.184.8]) by smtp.gmail.com with ESMTPSA id pj2sm8741334wjb.8.2016.10.05.05.12.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Oct 2016 05:12:38 -0700 (PDT) Received: by Jamess-MacBook.local (Postfix, from userid 501) id A3A724C1E76E; Wed, 5 Oct 2016 13:12:36 +0100 (BST) From: James Clarke To: gcc-patches@gcc.gnu.org Cc: James Clarke , Eric Botcazou Subject: [PATCH] Fix ICE for sparc targets in function_arg_record_value (PR target/77759) Date: Wed, 5 Oct 2016 13:12:26 +0100 Message-Id: <20161005121226.17590-1-jrtc27@jrtc27.com> gcc/ PR target/77759 * config/sparc/sparc.c (classify_data_t): Remove unused int_regs field. (classify_registers): Don't set int_regs. (function_arg_slotno): Don't initialise int_regs. Check slotno is within range for empty structs, just like int register-only structs. gcc/testsuite/ PR target/77759 * g++.dg/other/pr77759.C: New test. --- gcc/config/sparc/sparc.c | 10 +++------- gcc/testsuite/g++.dg/other/pr77759.C | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index c622b66..7af8ba1 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -6294,7 +6294,6 @@ traverse_record_type (const_tree type, bool named, T *data, typedef struct { - bool int_regs; /* true if field eligible to int registers. */ bool fp_regs; /* true if field eligible to FP registers. */ bool fp_regs_in_first_word; /* true if such field in first word. */ } classify_data_t; @@ -6311,8 +6310,6 @@ classify_registers (const_tree, HOST_WIDE_INT bitpos, bool fp, if (bitpos < BITS_PER_WORD) data->fp_regs_in_first_word = true; } - else - data->int_regs = true; } /* Compute the slot number to pass an argument in. @@ -6439,7 +6436,7 @@ function_arg_slotno (const struct sparc_args *cum, machine_mode mode, if (TREE_CODE (type) == RECORD_TYPE) { - classify_data_t data = { false, false, false }; + classify_data_t data = { false, false }; traverse_record_type (type, named, &data); @@ -6450,10 +6447,9 @@ function_arg_slotno (const struct sparc_args *cum, machine_mode mode, && slotno >= SPARC_FP_ARG_MAX - 1) return -1; - /* If there are only int args and all int slots are filled, - then must pass on stack. */ + /* If there are only int args or this is an empty record type, + and all int slots are filled, then must pass on stack. */ if (!data.fp_regs - && data.int_regs && slotno >= SPARC_INT_ARG_MAX) return -1; } diff --git a/gcc/testsuite/g++.dg/other/pr77759.C b/gcc/testsuite/g++.dg/other/pr77759.C new file mode 100644 index 0000000..4494bb5 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/pr77759.C @@ -0,0 +1,27 @@ +/* PR target/77759 + This testcase ICEd on sparc because function_arg_slotno did not treat empty + structs as being passed in integer registers and tried to assign the + struct pair_empty to register slot 6, causing function_arg_record_value to + fail the assertion that at least one register was available. */ +/* { dg-do compile { target sparc*-*-* } } */ + +struct empty {}; + +struct pair_empty +{ + struct empty a; + struct empty b; +}; + +void f1(int slot0 __attribute__((unused)), int slot1 __attribute__((unused)), + int slot2 __attribute__((unused)), int slot3 __attribute__((unused)), + int slot4 __attribute__((unused)), int slot5 __attribute__((unused)), + struct pair_empty pair __attribute__((unused))) +{ +} + +void f2(void) +{ + struct pair_empty pair; + f1(0, 0, 0, 0, 0, 0, pair); +}