PR ipa/59831 (ipa-cp devirt issues)

Jan Hubicka hubicka@ucw.cz
Fri Jan 31 21:28:00 GMT 2014


Hi,
this is variant of testcase that produces wrong code on Mainline.

$ ./xgcc -B ./ -O3 ~/t.C -S -fno-partial-inlining -fno-early-inlining -fdump-ipa-all ; g++ t.s; ./a.out
Aborted

The bug is that we determine wrong type on call of ~MultiTermDocs within ~C (it
is determined as C, while it really should be C in construction).
Quite amusingly gcc-4.8 also determine the wrong type but does devirtualize correctly.  Martin,
any idea why?


#include <stdlib.h>
class A {                                                                                                                                                                                       
public:                                                                                                                                                                                         
  unsigned length;                                                                                                                                                                              
};                                                                                                                                                                                              
class B {};                                                                                                                                                                                     
class MultiTermDocs : public virtual B {                                                                                                                                                        
protected:                                                                                                                                                                                      
  A readerTermDocs;                                                                                                                                                                             
  A subReaders;                                                                                                                                                                                 
  virtual B *m_fn1(int *) {}                                                                                                                                                                     
  inline virtual ~MultiTermDocs();                                                                                                                                                                     
  void wrap(void)
  {
  m_fn1(NULL);
  }
};                                                                                                                                                                                              
class C : MultiTermDocs {                                                                                                                                                                       
  B *m_fn1(int *);                                                                                                                                                                              
};                                                                                                                                                                                              
MultiTermDocs::~MultiTermDocs() {                                                                                                                                                               
  wrap ();
  if (&readerTermDocs) {                                                                                                                                                                        
    B *a;                                                                                                                                                                                       
    for (unsigned i = 0; i < subReaders.length; i++)                                                                                                                                            
      (a != 0);                                                                                                                                                                                 
  }                                                                                                                                                                                             
}                                                                                                                                                                                               
                                                                                                                                                                                                
B *C::m_fn1(int *) { abort (); }                                                                                                                                                                
                                                                                                                                                                                                
main()
{
  class C c;
}



More information about the Gcc-patches mailing list