r218141 - In the Itanium ABI, move stuff to the comdat of variables with static init.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Sat Nov 1 10:50:58 PDT 2014


> Hmm, why do you not do this for static local variables? They have the same
> issue, as far as I can see.

I was playing with

struct S {
  static const int x;
};
// const int S::x = 42;
inline int *f() {
  static int y = S::x;
  return &y;
}
int *g() { return f(); }

and I can't get it to produce invalid code. The main difference is
that without a static constructor there is never an always run piece
of code that assumes that it has to write to y. We also put y in a rw
section even when S::x is defined, but I think that is a bug (and will
report it in a sec).

Having said that, it would probably be profitable to put the variable
and the guard in the same comdat as the inline function. Is that what
you had in mind?

Cheers,
Rafael



More information about the cfe-commits mailing list