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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
OK, it's a late IPA pass doing the clones it seems.  The scalar node got the
'const' stripped btw, but the call fntype still has it via the attributes.

It loses 'const' by

Old value = 252968993
New value = 251920417
set_const_flag_1 (node=<cgraph_node * 0x7ffff6530330 "foo"/1>, set_const=false,
looping=false, changed=0x7fffffffda5f) at
/home/rguenther/src/trunk/gcc/cgraph.cc:2696
2696              DECL_LOOPING_CONST_OR_PURE_P (node->decl) = false;
(gdb) bt
#0  set_const_flag_1 (node=<cgraph_node * 0x7ffff6530330 "foo"/1>, 
    set_const=false, looping=false, changed=0x7fffffffda5f)
    at /home/rguenther/src/trunk/gcc/cgraph.cc:2696
#1  0x0000000000da633f in cgraph_node::set_const_flag (
    this=<cgraph_node * const 0x7ffff6530330 "foo"/1>, set_const=false, 
    looping=false) at /home/rguenther/src/trunk/gcc/cgraph.cc:2789
#2  0x00000000015e2910 in tree_profiling ()
    at /home/rguenther/src/trunk/gcc/tree-profile.cc:818
#3  0x00000000015e2b9f in (anonymous namespace)::pass_ipa_tree_profile::execute
    (this=0x42a0c70) at /home/rguenther/src/trunk/gcc/tree-profile.cc:888

but the IL happily continues to treat the calls as 'const' because
flags_from_decl_or_type on the call fntype has

849       else if (TYPE_P (exp))
850         {
851           if (TYPE_READONLY (exp))
852             flags |= ECF_CONST;

note that __attribute__((pure)) is not duplicated on the type and so the
IPA profile effect will change the IL in fixup_cfg (), rewriting virtual
operands there.
making things consistent.

Reply via email to