From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 732 invoked by alias); 1 Apr 2015 06:32:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 714 invoked by uid 89); 1 Apr 2015 06:32:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 01 Apr 2015 06:32:08 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 5B4B8547435; Wed, 1 Apr 2015 08:32:04 +0200 (CEST) Date: Wed, 01 Apr 2015 06:32:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, law@rehdat.com, mliska@redhat.com, eboctazou@gcc.gnu.org Subject: Fix ICE with thunks taking scalars passed by reference Message-ID: <20150401063203.GA56578@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-04/txt/msg00003.txt.bz2 Hi, this patch solves ICE in the attached testcase on mingw32. The problem is that on Windows API long double is passed & returned by reference and while expanidng the tunk tail call, we get lost because we turn the parameter into SSA name and later need its address to pass it further. The patch extends hack https://gcc.gnu.org/ml/gcc-patches/2014-11/msg00423.html to handle not only non-registers but also registers. Bootstrapped/regtested ppc64-linux. OK? The bug reproduced with ICF, but I suppose it will turn into ice on any C++ covariant thunks taking scalar passed by reference. ng double func1 (long double x) { if (x > 0.0) return x; else if (x < 0.0) return -x; else return x; } long double func2 (long double x) { if (x > 0.0) return x; else if (x < 0.0) return -x; else return x; } PR ipa/65540 * calls.c (initialize_argument_information): When producing tail call also turn SSA_NAMES passed by references to original PARM_DECLs Index: calls.c =================================================================== --- calls.c (revision 221805) +++ calls.c (working copy) @@ -1321,6 +1321,15 @@ initialize_argument_information (int num && TREE_CODE (base) != SSA_NAME && (!DECL_P (base) || MEM_P (DECL_RTL (base))))) { + /* We may have turned the parameter value into an SSA name. + Go back to the original parameter so we can take the + address. */ + if (TREE_CODE (args[i].tree_value) == SSA_NAME) + { + gcc_assert (SSA_NAME_IS_DEFAULT_DEF (args[i].tree_value)); + args[i].tree_value = SSA_NAME_VAR (args[i].tree_value); + gcc_assert (TREE_CODE (args[i].tree_value) == PARM_DECL); + } /* Argument setup code may have copied the value to register. We revert that optimization now because the tail call code must use the original location. */