From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106798 invoked by alias); 5 Mar 2015 09:40:08 -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 106712 invoked by uid 55); 5 Mar 2015 09:40:03 -0000 From: "rguenther at suse dot de" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: REOPENED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 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: 2015-03/txt/msg00586.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65270 --- Comment #21 from 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 --- > 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.