public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "marxin at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/106816] noreturn/pure attributes are not set correctly on multiversioned functions
Date: Fri, 06 Jan 2023 15:17:12 +0000	[thread overview]
Message-ID: <bug-106816-4-NxChHXwcjI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106816-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106816

--- Comment #10 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Martin Jambor from comment #9)
> (In reply to Martin Liška from comment #6)
> > 
> > @Martin: Do we have a declaration cloning code for functions somewhere?
> 
> See e.g. cgraph_node::create_virtual_clone in cgraphclones.cc.  Unless
> you want to mess with the parameters,
> 
>   new_decl = copy_node (old_decl);
> 
> should be enough (and it should copy over the DECL_PURE and
> TREE_READLONY bit soo, I believe).

Thanks! So apparently, we call make_dispatcher_decl which makes only a partial
copy of a function_decl:

original decl:

 <function_decl 0x7ffff77ce500 f
    type <function_type 0x7ffff7656d20
        type <void_type 0x7ffff7644f18 void VOID
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7644f18
            pointer_to_this <pointer_type 0x7ffff764c000>>
        QI
        size <integer_cst 0x7ffff76460c0 constant 8>
        unit-size <integer_cst 0x7ffff76460d8 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7656d20
        arg-types <tree_list 0x7ffff7639d98 value <void_type 0x7ffff7644f18
void>>
        pointer_to_this <pointer_type 0x7ffff77ee498>>
    volatile nothrow public static decl_5 QI
/home/marxin/Programming/testcases/pr106816.c:2:6 align:8 warn_if_not_align:0
context <translation_unit_decl 0x7ffff762d168
/home/marxin/Programming/testcases/pr106816.c>
    attributes <tree_list 0x7ffff77de0c8
        purpose <identifier_node 0x7ffff77caa40 target
            normal local bindings <(nil)>>
        value <tree_list 0x7ffff77de078
            value <string_cst 0x7ffff77c29e0 type <array_type 0x7ffff77ccb28>
                readonly constant static "default\000">>
        chain <tree_list 0x7ffff77de0a0
            purpose <identifier_node 0x7ffff7650500 noreturn
                normal local bindings <(nil)>>>> initial <block 0x7ffff77d1420>
    result <result_decl 0x7ffff762df78 D.2761 type <void_type 0x7ffff7644f18
void>
        ignored VOID /home/marxin/Programming/testcases/pr106816.c:2:1
        align:8 warn_if_not_align:0 context <function_decl 0x7ffff77ce500 f>>
    full-name "void f()"
    struct-function 0x7ffff77df000 chain <function_decl 0x7ffff77cbc00
__cxa_call_unexpected>>

dispatcher:

(gdb) p debug_tree(func_decl)
 <function_decl 0x7ffff77efd00 _Z1fv
    type <function_type 0x7ffff7656d20
        type <void_type 0x7ffff7644f18 void VOID
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7644f18
            pointer_to_this <pointer_type 0x7ffff764c000>>
        QI
        size <integer_cst 0x7ffff76460c0 constant 8>
        unit-size <integer_cst 0x7ffff76460d8 constant 1>
        align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7ffff7656d20
        arg-types <tree_list 0x7ffff7639d98 value <void_type 0x7ffff7644f18
void>>
        pointer_to_this <pointer_type 0x7ffff77ee498>>
    nothrow public external QI
/home/marxin/Programming/testcases/pr106816.c:15:1 align:8 warn_if_not_align:0>

So we modify the name, drop 'target' attribute, and so on. Thus we can't use
copy_node.


> 
> I am not sure at what point the duplication happens, in order to
> duplicate also all the various IPA summaries, cgraph machinery has to
> be involved and call all the summary hooks.  So
> cgraph_node::create_clone should probably be used (or a part of it, or
> perhaps even one of its users?).

It can happen during the multiple_target.cc IPA pass, so lemme combine the
H.J.'s approach
and cgraph_node::create_clone.

  parent reply	other threads:[~2023-01-06 15:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 15:34 [Bug ipa/106816] New: " gcc.gnu at vvalter dot com
2022-09-02 17:26 ` [Bug ipa/106816] " hjl.tools at gmail dot com
2022-09-02 17:55 ` gcc.gnu at vvalter dot com
2022-09-02 18:39 ` hjl.tools at gmail dot com
2022-09-02 19:48 ` gcc.gnu at vvalter dot com
2022-09-05 10:02 ` rguenth at gcc dot gnu.org
2022-09-14 13:58 ` marxin at gcc dot gnu.org
2022-09-14 13:59 ` marxin at gcc dot gnu.org
2022-12-28 14:50 ` marxin at gcc dot gnu.org
2023-01-03 10:27 ` jamborm at gcc dot gnu.org
2023-01-06 15:17 ` marxin at gcc dot gnu.org [this message]
2023-04-03  9:03 ` marxin at gcc dot gnu.org
2023-04-26  6:56 ` rguenth at gcc dot gnu.org
2023-07-27  9:23 ` rguenth at gcc dot gnu.org
2024-05-21  9:12 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-106816-4-NxChHXwcjI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).