public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/65270] [5 regression] ICF needs to match TYPE attributes on memory accesses
Date: Thu, 05 Mar 2015 09:40:00 -0000	[thread overview]
Message-ID: <bug-65270-4-C4KIDXOIzQ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65270-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #21 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 4 Mar 2015, hubicka at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65270
> 
> --- Comment #16 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
> Richard,
> thanks, I also think alias trick makes gloal vars safe for merging across
> RESTRICT flags. 
> 
> One however needs to consider merging of items referring restricted vars.
> 
> const restrict int *a=&var;
> const int *b = &var; 
> 
> const int **ptrs1={&a};
> const int **ptrs2=[&b};
> 
> with -fmerge-all-constants we may merge ptrs1 and ptrs2 and, in the late
> compilation, in turn fold expression "ptrs2[0]" into a restricted pointer to
> var?

So we merge a and b with introducing an alias which is why we can
merge ptrs1 and ptrs2, correct?  But still with introducing an
alias.  But folding ptrs1[0] and ptrs2[0] will now return the same
(but random?) value.

Note that it's not folding that can introduce issues but points-to
analysis and what it computes for the globals ptrs1 and ptrs2
and thus for code that reads from them.

We are not really parsing constructors fully in PTA - at least I see

ptrs1 = NONLOCAL
ptrs1.0_2 = ptrs1
_3 = *ptrs1.0_2 
_4 = *_3        

only for

int var;
const int * restrict a=&var;
const int *b = &var;

const int * const *ptrs1={&a};
const int * const *ptrs2={&b};

int main()
{
  return *(ptrs1[0]);
}

IPA PTA does sth funny though:

ptrs2 = NONLOCAL
b = NONLOCAL
var = NONLOCAL
b = &var
ESCAPED = &var
ptrs2 = &b
ESCAPED = &b
ptrs1 = NONLOCAL
a = &GLOBAL_RESTRICT
GLOBAL_RESTRICT = NONLOCAL
ptrs1 = &a
ESCAPED = &a

but obviously we don't seem to merge ptrs1/ptrs2.  But IPA PTA
needs quite some thoughts with respect to aliases I think (and
in other ways as well...).

> If this case is legit, the correct place to match RESTRICT flags is
> compare_cgraph_references. We can also go with your patch that will make A and
> B considered to be different and thus prevent merging PTRS1&PTRS2.

That would certainly be a safe thing to do.

Even with -flto -fmerge-all-constants we don't get ptrs1 and ptrs2
merged it seems (with -fwhole-program we fold stuff too early).

Richard.


  parent reply	other threads:[~2015-03-05  9:40 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02  0:49 [Bug ipa/65270] New: " hubicka at gcc dot gnu.org
2015-03-02  8:58 ` [Bug ipa/65270] " rguenth at gcc dot gnu.org
2015-03-02 11:50 ` rguenth at gcc dot gnu.org
2015-03-02 14:32 ` rguenth at gcc dot gnu.org
2015-03-02 14:51 ` rguenth at gcc dot gnu.org
2015-03-02 18:25 ` hubicka at gcc dot gnu.org
2015-03-03 14:57 ` rguenther at suse dot de
2015-03-03 15:08 ` howarth at bromo dot med.uc.edu
2015-03-03 17:24 ` rguenther at suse dot de
2015-03-03 18:23 ` hubicka at gcc dot gnu.org
2015-03-03 20:38 ` hubicka at gcc dot gnu.org
2015-03-04  9:26 ` rguenth at gcc dot gnu.org
2015-03-04  9:45 ` rguenther at suse dot de
2015-03-04 10:35 ` rguenth at gcc dot gnu.org
2015-03-04 11:52 ` rguenth at gcc dot gnu.org
2015-03-04 11:57 ` rguenth at gcc dot gnu.org
2015-03-04 18:21 ` hubicka at gcc dot gnu.org
2015-03-05  0:11 ` hubicka at gcc dot gnu.org
2015-03-05  0:21 ` hubicka at gcc dot gnu.org
2015-03-05  0:42 ` hubicka at gcc dot gnu.org
2015-03-05  8:43 ` rguenth at gcc dot gnu.org
2015-03-05  9:40 ` rguenther at suse dot de [this message]
2015-03-05  9:42 ` rguenther at suse dot de
2015-03-05  9:45 ` rguenther at suse dot de
2015-03-05 11:30 ` marxin at gcc dot gnu.org
2015-03-05 19:47 ` [Bug ipa/65270] issues with merging memory accesses from different code paths hubicka at gcc dot gnu.org
2015-03-05 19:59 ` hubicka at gcc dot gnu.org
2015-03-05 20:11 ` hubicka at gcc dot gnu.org
2015-03-05 21:18 ` hubicka at gcc dot gnu.org
2015-03-06  8:32 ` rguenther at suse dot de
2015-03-06 15:41 ` hubicka at gcc dot gnu.org
2015-03-06 18:03 ` [Bug ipa/65270] [5 regression] " hubicka at gcc dot gnu.org
2015-03-09 11:11 ` rguenth at gcc dot gnu.org
2015-03-09 13:55 ` rguenth at gcc dot gnu.org
2015-03-09 13:55 ` rguenth at gcc dot gnu.org
2015-03-12 13:03 ` rguenth 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-65270-4-C4KIDXOIzQ@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).