From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20695 invoked by alias); 6 May 2014 11:28:21 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 20645 invoked by uid 48); 6 May 2014 11:28:16 -0000 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/60973] Invalid propagation of a tail call in devirt pass Date: Tue, 06 May 2014 11:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 4.10.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg00354.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60973 --- Comment #2 from Jan Hubicka --- I wonder if the tailcall flag can't be reliably set by tree-tailcall, but i suppose we want tailcall in thunks even at -O0. The patch seems fine to me. Note that this is not ipa-devirt issue, just semi-latent bug, so this probably should be backported to all release branches. The effect of CALL_FROM_THUNK is the following: /* If we're compiling a thunk, pass through invisible references instead of making a copy. */ if (call_from_thunk_p || (callee_copies && !TREE_ADDRESSABLE (type) && (base = get_base_address (args[i].tree_value)) && TREE_CODE (base) != SSA_NAME && (!DECL_P (base) || MEM_P (DECL_RTL (base))))) { I am not really confident about this code, but I would say that if we inlined the thunk itself, we still should have the copy around - at least I do not see any code in tree-inline that would copy propagate this through. So probably we do not need to make the another copy? This may be true in general for all parameters passed by invisible references that was passed to caller same way and caller does not modify them or use after the call. This seems just special case of this optimization.