This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Compilation of object creation in C++



We are working on an analysis for identifying the class of an object flow sensitively for
flow sensitive de-virtualization (i.e. replacing a virtual function call by a call to the
function of a known class in the hierarchy). This is a regular ipa pass. It find outs the
class of an object at point of creation and then propagates it.

In the examples we have seen so far, given a statement

  B beta ("str");

It is is transformed by gcc-4.7.2 as shown below :

     __comp_ctor  (&beta, "str");

We use this information to identify the class.

However, for case in the source of GNU package gperf-3.0.4, a statement

      Output_Enum style ("  ");

is transformed by gcc 4.7.2 as

      # DEBUG this => &style
      # DEBUG indent => ""
      # DEBUG D#62 => &style.D.4064
      # DEBUG this => D#62
      MEM[(struct Output_Constants *)&style]._vptr.Output_Constants = &MEM[(void *)&_ZTV16Output_Constants + 16B];
      style.D.4064._vptr.Output_Constants = &MEM[(void *)&_ZTV11Output_Enum + 16B];
      style._indentation = "";

Why is this different? Why is __comp_ctor not invoked in each case?

The class hierarchy in gperf is as given below :

struct Output_Constants
{
  virtual void          output_start () = 0;
  virtual void          output_item (const char *name, int value) = 0;
  virtual void          output_end () = 0;
                        Output_Constants () {}
  virtual               ~Output_Constants () {}
};

struct Output_Enum : public Output_Constants
{
  virtual void          output_start ();
  virtual void          output_item (const char *name, int value);
  virtual void          output_end ();
                        Output_Enum (const char *indent)
                          : _indentation (indent) {}
  virtual               ~Output_Enum () {}
private:
  const char *_indentation;
  bool _pending_comma;
};

Thanks and regards,

Uday Khedker.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]