From patchwork Tue Aug 6 21:20:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oleg Endo X-Patchwork-Id: 265244 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id CB7902C00A7 for ; Wed, 7 Aug 2013 07:21:14 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; q=dns; s=default; b=O/g0mKntYY2jbRFy cnn6yCAnXgWApnu8arCaKXq+NkStK2DUeV/NnF1rO1MsCqjt90NVhFtULHmKYeOc IhdhJfCz3lHpunv0UjCXg5+kbZQuijzot2ivGa1DyLJR3ZKDNFK8tyiNizFWZUEB rIpAltY3gufS3g69E9Clp/G9xcs= 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 :message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version; s=default; bh=o+58z7SLTHNRi5xaObMHFY rYyeU=; b=oP4HrVUMi+cC8tGL6ngdapOToIgvcx7QyxgejshdC1Bc/w+BcAeO79 RjYwNuXPO10sGU2H3IlXbI2vwbLavDDuw1Vz71i1pyaWfxf72qSdVbbgPvC6gZGW rsotp51cDPnRJ9EaAy/XOCBqVw43lbD2KbUyUMV6xQiXu+zPGiSHQ= Received: (qmail 30019 invoked by alias); 6 Aug 2013 21:21:07 -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 29993 invoked by uid 89); 6 Aug 2013 21:21:07 -0000 X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_YE, RDNS_NONE, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from Unknown (HELO mailout08.t-online.de) (194.25.134.20) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 06 Aug 2013 21:21:06 +0000 Received: from fwd10.aul.t-online.de (fwd10.aul.t-online.de ) by mailout08.t-online.de with smtp id 1V6ogZ-0004qY-TT; Tue, 06 Aug 2013 23:20:55 +0200 Received: from [192.168.0.103] (Zq0faZZcYhHZz1kM3ApDAmtaTWL0cXuSOgtPn+8vGDA3A-lbY0lAPpxhh5mZdaSQvu@[93.195.27.216]) by fwd10.t-online.de with esmtp id 1V6ogR-0kIoam0; Tue, 6 Aug 2013 23:20:47 +0200 Message-ID: <1375824046.3952.84.camel@yam-132-YW-E178-FTW> Subject: Re: [buildbot] r201513: Invalid cast From: Oleg Endo To: Jan-Benedict Glaw Cc: gcc-patches@gcc.gnu.org, Richard Henderson Date: Tue, 06 Aug 2013 23:20:46 +0200 In-Reply-To: <20130806112702.GC16320@lug-owl.de> References: <20130805220945.22067.qmail@sourceware.org> <20130806112702.GC16320@lug-owl.de> Mime-Version: 1.0 X-Virus-Found: No On Tue, 2013-08-06 at 13:27 +0200, Jan-Benedict Glaw wrote: > Hi! > > On Mon, 2013-08-05 22:09:45 -0000, olegendo@gcc.gnu.org wrote: > > Author: olegendo > > Date: Mon Aug 5 22:09:45 2013 > > New Revision: 201513 > > > > URL: http://gcc.gnu.org/viewcvs?rev=201513&root=gcc&view=rev > > Log: > > PR other/12081 > > * recog.h (rtx (*insn_gen_fn) (rtx, ...)): Replace typedef with new > > class insn_gen_fn. > > * expr.c (move_by_pieces_1, store_by_pieces_2): Replace argument > > rtx (*) (rtx, ...) with insn_gen_fn. > > * genoutput.c (output_insn_data): Cast gen_? function pointers to > > insn_gen_fn::stored_funcptr. Add initializer braces. > > This probably caused in a powerpc64-linux build: > > g++ -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -I. -I. -I../../../../gcc/gcc -I../../../../gcc/gcc/. -I../../../../gcc/gcc/../include -I../../../../gcc/gcc/../libcpp/include -I../../../../gcc/gcc/../libdecnumber -I../../../../gcc/gcc/../libdecnumber/dpd -I../libdecnumber -I../../../../gcc/gcc/../libbacktrace \ > ../../../../gcc/gcc/config/rs6000/rs6000.c -o rs6000.o > In file included from ../../../../gcc/gcc/config/rs6000/rs6000.c:36:0: > ../../../../gcc/gcc/config/rs6000/rs6000.c: In function ‘void rs6000_emit_swdiv(rtx, rtx, rtx, bool)’: > ../../../../gcc/gcc/optabs.h:47:46: error: invalid cast from type ‘const insn_gen_fn’ to type ‘gen_2arg_fn_t {aka rtx_def* (*)(rtx_def*, rtx_def*, rtx_def*)}’ > #define GEN_FCN(CODE) (insn_data[CODE].genfun) > ^ > ../../../../gcc/gcc/config/rs6000/rs6000.c:28145:43: note: in expansion of macro ‘GEN_FCN’ > gen_2arg_fn_t gen_mul = (gen_2arg_fn_t) GEN_FCN (code); > ^ > ../../../../gcc/gcc/config/rs6000/rs6000.c: In function ‘void rs6000_emit_swrsqrt(rtx, rtx)’: > ../../../../gcc/gcc/optabs.h:47:46: error: invalid cast from type ‘const insn_gen_fn’ to type ‘gen_2arg_fn_t {aka rtx_def* (*)(rtx_def*, rtx_def*, rtx_def*)}’ > #define GEN_FCN(CODE) (insn_data[CODE].genfun) > ^ > ../../../../gcc/gcc/config/rs6000/rs6000.c:28223:43: note: in expansion of macro ‘GEN_FCN’ > gen_2arg_fn_t gen_mul = (gen_2arg_fn_t) GEN_FCN (code); > ^ > > Other PPC/RS6k targets (ie. rs6000-ibm-aix4.3, ...) seem to be equally > affected. That gen_2arg_fn_t typedef looks strange. In other places where GEN_FCN is used in similar ways in rs6000.c, there's no cast to a function pointer with an explicit number of arguments. It's not clear to me what it's trying to achieve there. I've briefly tested the attached patch by building a powerpc-elf cross compiler with make all-gcc and checking that it can produce some assembly code. Is this OK for trunk? Speaking of GEN_FCN usage in rs6000.c. The recently added HTM builtin code has one interesting piece: static rtx htm_expand_builtin (tree exp, rtx target, bool * expandedp) { ... switch (nopnds) { case 0: pat = GEN_FCN (icode) (NULL_RTX); break; case 1: pat = GEN_FCN (icode) (op[0]); break; The 'case 0' looks suspicious. If the function behind the pointer really is a zero-arg function this might or might not work depending on the ABI. I'm not sure what the intention here is. I've compiled gcc/testsuite/gcc.target/powerpc/htm-builtin-1.c to see if it ever gets into the 'case 0' but it doesn't. The function 'htm_init_builtins' doesn't seem to handle a 'case 0'. I'm confused, somebody else should have a look at this please. Cheers, Oleg gcc/ChangeLog: PR other/12081 config/rs6000/rs6000.c (gen_2arg_fn_t): Remove typedef. (rs6000_emit_swdiv, rs6000_emit_swrsqrt): Don't cast result of GEN_FCN to gen_2arg_fn_t. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 201512) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -284,9 +284,6 @@ { "rsqrtd", (RECIP_DF_RSQRT | RECIP_V2DF_RSQRT) }, }; -/* 2 argument gen function typedef. */ -typedef rtx (*gen_2arg_fn_t) (rtx, rtx, rtx); - /* Pointer to function (in rs6000-c.c) that can define or undefine target macros that have changed. Languages that don't support the preprocessor don't link in rs6000-c.c, so we can't call it directly. */ @@ -28142,7 +28139,7 @@ passes++; enum insn_code code = optab_handler (smul_optab, mode); - gen_2arg_fn_t gen_mul = (gen_2arg_fn_t) GEN_FCN (code); + insn_gen_fn gen_mul = GEN_FCN (code); gcc_assert (code != CODE_FOR_nothing); @@ -28220,7 +28217,7 @@ int i; rtx halfthree; enum insn_code code = optab_handler (smul_optab, mode); - gen_2arg_fn_t gen_mul = (gen_2arg_fn_t) GEN_FCN (code); + insn_gen_fn gen_mul = GEN_FCN (code); gcc_assert (code != CODE_FOR_nothing);