Message ID | 20151211111610.GC3956@virgil.suse.cz |
---|---|
State | New |
Headers | show |
On Fri, Dec 11, 2015 at 12:16 PM, Martin Jambor <mjambor@suse.cz> wrote: > Hi, > > PR 68064 has been fixed by Richi's revision 231246. I would still > like to add the testcase to the testsuite and add a checking assert > so that if ever get zero alignment again, we catch it in the analysis > part of IPA-CP (which with LTO means in compilation and not linking > phase which makes a big difference for debugging). > > I have tossed this into a bootstrap and test run on an x86_64-linux > and found no issues. I believe the patch is quite obvious and so will > go ahead and commit it to trunk. > > Thanks, > > Martin > > > Add asssert and testcase for PR 68064 > > 2015-12-09 Martin Jambor <mjambor@suse.cz> > > * ipa-prop.c (ipa_compute_jump_functions_for_edge): Add checking > assert that align is nonzero. > > testsuite/ > * g++.dg/torture/pr68064.C: New test. > --- > gcc/ipa-prop.c | 1 + > gcc/testsuite/g++.dg/torture/pr68064.C | 35 ++++++++++++++++++++++++++++++++++ > 2 files changed, 36 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/torture/pr68064.C > > diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c > index f379ea7..d0a3501 100644 > --- a/gcc/ipa-prop.c > +++ b/gcc/ipa-prop.c > @@ -1646,6 +1646,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, > && align % BITS_PER_UNIT == 0 > && hwi_bitpos % BITS_PER_UNIT == 0) > { > + gcc_checking_assert (align != 0); > jfunc->alignment.known = true; > jfunc->alignment.align = align / BITS_PER_UNIT; don't you want to assert align / BITS_PER_UNIT is not 0? > jfunc->alignment.misalign = hwi_bitpos / BITS_PER_UNIT; > diff --git a/gcc/testsuite/g++.dg/torture/pr68064.C b/gcc/testsuite/g++.dg/torture/pr68064.C > new file mode 100644 > index 0000000..59b6897 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/torture/pr68064.C > @@ -0,0 +1,35 @@ > +// { dg-do compile } > + > +template <class Config> class A { > +public: > + class B; > + typedef typename Config::template D<A>::type TypeHandle; > + static A *Tagged() { return B::New(B::kTagged); } > + static TypeHandle Union(TypeHandle); > + static TypeHandle Representation(TypeHandle, typename Config::Region *); > + bool Is(); > +}; > + > +template <class Config> class A<Config>::B { > + friend A; > + enum { kTaggedPointer = 1 << 31, kTagged = kTaggedPointer }; > + static A *New(int p1) { return Config::from_bitset(p1); } > +}; > + > +struct C { > + typedef int Region; > + template <class> struct D { typedef A<C> *type; }; > + static A<C> *from_bitset(unsigned); > +}; > +A<C> *C::from_bitset(unsigned p1) { return reinterpret_cast<A<C> *>(p1); } > + > +namespace { > +int *a; > +void fn1(A<C> *p1) { A<C>::Union(A<C>::Representation(p1, a)); } > +} > + > +void fn2() { > + A<C> b; > + A<C> *c = b.Is() ? 0 : A<C>::Tagged(); > + fn1(c); > +} > -- > 2.6.3 >
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index f379ea7..d0a3501 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -1646,6 +1646,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi, && align % BITS_PER_UNIT == 0 && hwi_bitpos % BITS_PER_UNIT == 0) { + gcc_checking_assert (align != 0); jfunc->alignment.known = true; jfunc->alignment.align = align / BITS_PER_UNIT; jfunc->alignment.misalign = hwi_bitpos / BITS_PER_UNIT; diff --git a/gcc/testsuite/g++.dg/torture/pr68064.C b/gcc/testsuite/g++.dg/torture/pr68064.C new file mode 100644 index 0000000..59b6897 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr68064.C @@ -0,0 +1,35 @@ +// { dg-do compile } + +template <class Config> class A { +public: + class B; + typedef typename Config::template D<A>::type TypeHandle; + static A *Tagged() { return B::New(B::kTagged); } + static TypeHandle Union(TypeHandle); + static TypeHandle Representation(TypeHandle, typename Config::Region *); + bool Is(); +}; + +template <class Config> class A<Config>::B { + friend A; + enum { kTaggedPointer = 1 << 31, kTagged = kTaggedPointer }; + static A *New(int p1) { return Config::from_bitset(p1); } +}; + +struct C { + typedef int Region; + template <class> struct D { typedef A<C> *type; }; + static A<C> *from_bitset(unsigned); +}; +A<C> *C::from_bitset(unsigned p1) { return reinterpret_cast<A<C> *>(p1); } + +namespace { +int *a; +void fn1(A<C> *p1) { A<C>::Union(A<C>::Representation(p1, a)); } +} + +void fn2() { + A<C> b; + A<C> *c = b.Is() ? 0 : A<C>::Tagged(); + fn1(c); +}