This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Enable pointer TBAA for LTO
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Richard Biener <rguenther at suse dot de>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Bernd Schmidt <bschmidt at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Nov 2015 05:02:28 +0100
- Subject: Re: Enable pointer TBAA for LTO
- Authentication-results: sourceware.org; auth=none
- References: <20151108204618 dot GA68715 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1511101306050 dot 10078 at zhemvz dot fhfr dot qr> <20151110181515 dot GB78110 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1511111019350 dot 7543 at zhemvz dot fhfr dot qr> <564337E7 dot 2070802 at redhat dot com> <20151111221359 dot GA93507 at kam dot mff dot cuni dot cz> <20151111223121 dot GA88599 at kam dot mff dot cuni dot cz> <20151122230025 dot GA85269 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1511231131480 dot 4884 at t29 dot fhfr dot qr>
> I don't understand why we need this (testcase?) because get_alias_set ()
> is supposed to do the alias-set of pointer globbing for us.
Hi,
After some experimentation I managed to derive self contained testcase (other than GCC itself).
struct a/b/c gets the same TYPE_CANONICAL which is different from struct b. Without that
change in recording component aliases then the alias_set of struct b has component float *
instead of int *. Eventually in main we optimize out the store to int * because we do not
see the conflict.
One needs to add the extra garbage around to be sure that things are streamed
in proper order and also in proper order shipped to ltrans and finally the
gimple optimizers are not smart enough to get the propagation without TBAA
oracle help.
Comitted.
* gcc.c-torture/execute/lto-tbaa-1.c: New testcase.
Index: gcc.c-torture/execute/lto-tbaa-1.c
===================================================================
--- gcc.c-torture/execute/lto-tbaa-1.c (revision 0)
+++ gcc.c-torture/execute/lto-tbaa-1.c (revision 0)
@@ -0,0 +1,42 @@
+/* { dg-additional-options "-fno-early-inlining -fno-ipa-cp" } */
+struct a {
+ float *b;
+} *a;
+struct b {
+ int *b;
+} b;
+struct c {
+ float *b;
+} *c;
+int d;
+use_a (struct a *a)
+{
+}
+set_b (int **a)
+{
+ *a=&d;
+}
+use_c (struct c *a)
+{
+}
+__attribute__ ((noinline)) int **retme(int **val)
+{
+ return val;
+}
+int e;
+struct b b= {&e};
+struct b b2;
+struct b b3;
+int **ptr = &b2.b;
+main ()
+{
+ a= (void *)0;
+ b.b=&e;
+ ptr =retme ( &b.b);
+ set_b (ptr);
+ b3=b;
+ if (b3.b != &d)
+ __builtin_abort ();
+ c= (void *)0;
+ return 0;
+}