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]

Re: lto gimple types and debug info


Daniel Berlin wrote:

If you built an AST that included sizeof before doing template
instantiation (which may not even be possible), you could at least
determine whether sizeof was used on a given type other than in a
malloc/new call (which we replace anyway).

Even if you did, I am allowed to know the ABI.


I can know that struct S has size 12 on this ABI, and do things like:

  struct S a[3];
  struct S* p = &a[0];
  /* This points at a[1].  */
  struct S* q = ((char *)p) + 12;

You cannot shrink S in that situation. In C, you also have to handle the "common prefix" problem, where the members of S are the first few members of a larger structure T. I'm then allowed to cast between an S* and a T*, and if you shrink S, things will break.

So, these kinds of optimizations, where you rip fields out of a structure are only safe if you can prove that addresses don't escape -- or if the user explicitly tells you that they are.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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