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: Proposed resolution to aliasing issue.


Mark,
it occurred to me that asking the question you pose may use language that is 
more unfamiliar than necessary. How about this question instead -- assume

  struct S { int s; };
  struct X {
    int i;
    struct S s;
  };

  void g(struct S*);
  void f() {
    X x;
    g(&x.s);
  }

Would the compiler be allowed to realize that X::i is never referenced and 
therefore a dead variable? I assume the compiler doesn't do that right now, 
but it would be straightforward for a scalar replacement algorithm to not 
even allocate stack space for X::i, but only X::s, and hand the address of 
the only remaining stack object, of type S, to g().

The community at large may have more experience with such "as-if" related 
questions. It would be interested to know whether the scalarizers in gcc 
realize, for example, whether they can/can't get rid of X::i...

Best
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/


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