diff mbox

Fix thunk expansion (PR ipa/64896)

Message ID CAD57uCemOtM8dO7yC-H5gaGr7DKzju=0kTFd0cpNMdnO1io3Vw@mail.gmail.com
State New
Headers show

Commit Message

Yvan Roux March 11, 2015, 3:38 p.m. UTC
Hi,


>>>         PR ipa/65236
>>>         * cgraphunit.c (cgraph_node::expand_thunk): Enable return slot
>>>         opt.
>
> This bugfix adds ipa-icf-6.C test which failed on 4.9 branch as
> ipa-icf is not backported on that branch.  Is the bugfix still
> relevant and we can dropped the testcase ?
>
>>>         PR ipa/64813
>>>         * cgraphunit.c (cgraph_node::expand_thunk): Do not create
>>>         a return value for call to a function that is noreturn.
>>>
>>>         PR ipa/63595
>>>         * cgraphunit.c (cgraph_node::expand_thunk): DECL_BY_REFERENCE
>>>         is correctly handled for thunks created by IPA ICF.
>>>
>>>         PR ipa/63587
>>>         * cgraphunit.c (cgraph_node::expand_thunk): Only VAR_DECLs are put
>>>         to local declarations.
>>>         * function.c (add_local_decl): Implementation moved from header
>>>         file, assert introduced for tree type.
>>>         * function.h: Likewise.

Here is the two patches that backport PR ipa/63587 and PR ipa/64813
fixes in 4.9 branch.  The 2 others introduce test cases that check
ipa-icf pass dumps, so I'm not sure if the code has to be backported.

bootstrapped/regtested on x86_64 and cross-compiled/regtested on
aarch64-linux-gnu
arm-linux-gnueabihf
armeb-linux-gnueabihf
i686-linux-gnu

Ok for 4.9 ?

Thanks
Yvan

----- PR 63587 -----
gcc/
2015-03-11  Yvan Roux  <yvan.roux@linaro.org>

    Backport from trunk r216841.
    2014-10-29  Martin Liska  <mliska@suse.cz>

    PR ipa/63587
    * cgraphunit.c (cgraph_node::expand_thunk): Only VAR_DECLs are put
    to local declarations.
    * function.c (add_local_decl): Implementation moved from header
    file, assert introduced for tree type.
    * function.h: Likewise.

gcc/testsuite/
2015-03-11  Yvan Roux  <yvan.roux@linaro.org>

    Backport from trunk r216841.
    2014-10-29  Martin Liska  <mliska@suse.cz>

    PR ipa/63587
    * g++.dg/ipa/pr63587-1.C: New test.
    * g++.dg/ipa/pr63587-2.C: New test.

----- PR 64813 -----
2015-03-11  Yvan Roux  <yvan.roux@linaro.org>

    Backport from trunk r220616.
    2015-02-11  Martin Liska  <mliska@suse.cz>

    PR ipa/64813
    * cgraphunit.c (cgraph_node::expand_thunk): Do not create
    a return value for call to a function that is noreturn.

Comments

Yvan Roux March 20, 2015, 9:05 a.m. UTC | #1
Ping.

On 11 March 2015 at 16:38, Yvan Roux <yvan.roux@linaro.org> wrote:
> Hi,
>
>
>>>>         PR ipa/65236
>>>>         * cgraphunit.c (cgraph_node::expand_thunk): Enable return slot
>>>>         opt.
>>
>> This bugfix adds ipa-icf-6.C test which failed on 4.9 branch as
>> ipa-icf is not backported on that branch.  Is the bugfix still
>> relevant and we can dropped the testcase ?
>>
>>>>         PR ipa/64813
>>>>         * cgraphunit.c (cgraph_node::expand_thunk): Do not create
>>>>         a return value for call to a function that is noreturn.
>>>>
>>>>         PR ipa/63595
>>>>         * cgraphunit.c (cgraph_node::expand_thunk): DECL_BY_REFERENCE
>>>>         is correctly handled for thunks created by IPA ICF.
>>>>
>>>>         PR ipa/63587
>>>>         * cgraphunit.c (cgraph_node::expand_thunk): Only VAR_DECLs are put
>>>>         to local declarations.
>>>>         * function.c (add_local_decl): Implementation moved from header
>>>>         file, assert introduced for tree type.
>>>>         * function.h: Likewise.
>
> Here is the two patches that backport PR ipa/63587 and PR ipa/64813
> fixes in 4.9 branch.  The 2 others introduce test cases that check
> ipa-icf pass dumps, so I'm not sure if the code has to be backported.
>
> bootstrapped/regtested on x86_64 and cross-compiled/regtested on
> aarch64-linux-gnu
> arm-linux-gnueabihf
> armeb-linux-gnueabihf
> i686-linux-gnu
>
> Ok for 4.9 ?
>
> Thanks
> Yvan
>
> ----- PR 63587 -----
> gcc/
> 2015-03-11  Yvan Roux  <yvan.roux@linaro.org>
>
>     Backport from trunk r216841.
>     2014-10-29  Martin Liska  <mliska@suse.cz>
>
>     PR ipa/63587
>     * cgraphunit.c (cgraph_node::expand_thunk): Only VAR_DECLs are put
>     to local declarations.
>     * function.c (add_local_decl): Implementation moved from header
>     file, assert introduced for tree type.
>     * function.h: Likewise.
>
> gcc/testsuite/
> 2015-03-11  Yvan Roux  <yvan.roux@linaro.org>
>
>     Backport from trunk r216841.
>     2014-10-29  Martin Liska  <mliska@suse.cz>
>
>     PR ipa/63587
>     * g++.dg/ipa/pr63587-1.C: New test.
>     * g++.dg/ipa/pr63587-2.C: New test.
>
> ----- PR 64813 -----
> 2015-03-11  Yvan Roux  <yvan.roux@linaro.org>
>
>     Backport from trunk r220616.
>     2015-02-11  Martin Liska  <mliska@suse.cz>
>
>     PR ipa/64813
>     * cgraphunit.c (cgraph_node::expand_thunk): Do not create
>     a return value for call to a function that is noreturn.
diff mbox

Patch

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 130fc0d..2fcb84c 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1532,6 +1532,7 @@  expand_thunk (struct cgraph_node *node, bool output_asm_thunks)
 
       gimple call;
       gimple ret;
+      bool alias_is_noreturn = TREE_THIS_VOLATILE (alias);
 
       if (in_lto_p)
 	cgraph_get_body (node);
@@ -1566,7 +1567,7 @@  expand_thunk (struct cgraph_node *node, bool output_asm_thunks)
       bsi = gsi_start_bb (bb);
 
       /* Build call to the function being thunked.  */
-      if (!VOID_TYPE_P (restype))
+      if (!VOID_TYPE_P (restype) && !alias_is_noreturn)
 	{
 	  if (DECL_BY_REFERENCE (resdecl))
 	    restmp = gimple_fold_indirect_ref (resdecl);
@@ -1610,14 +1611,14 @@  expand_thunk (struct cgraph_node *node, bool output_asm_thunks)
       call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), vargs);
       node->callees->call_stmt = call;
       gimple_call_set_from_thunk (call, true);
-      if (restmp)
+      if (restmp && !alias_is_noreturn)
 	{
           gimple_call_set_lhs (call, restmp);
 	  gcc_assert (useless_type_conversion_p (TREE_TYPE (restmp),
 						 TREE_TYPE (TREE_TYPE (alias))));
 	}
       gsi_insert_after (&bsi, call, GSI_NEW_STMT);
-      if (!(gimple_call_flags (call) & ECF_NORETURN))
+      if (!alias_is_noreturn)
 	{
 	  if (restmp && !this_adjusting
 	      && (fixed_offset || virtual_offset))
-- 
1.9.1