I think we should have clang omit comdats, it would be confusing to silently ignore comdats in llvm.<br><br>On Tuesday, September 16, 2014, Rafael Espíndola <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Clang can already handle<br>
<br>
-------------------------------------------<br>
struct S {<br>
  static const int x;<br>
};<br>
template<typename T> struct U {<br>
  static const int k;<br>
};<br>
template<typename T> const int U<T>::k = T::x;<br>
<br>
#ifdef TU1<br>
const int S::x = 42;<br>
extern const int *f();<br>
const int *g() { return &U<S>::k; }<br>
int main() {<br>
  return *f() + U<S>::k;<br>
}<br>
#endif<br>
<br>
#ifdef TU2<br>
const int *f() { return &U<S>::k; }<br>
#endif<br>
-------------------------------------------<br>
<br>
since r217264 which puts the .inint_array section in the same COMDAT<br>
as the variable.<br>
<br>
The attached patch allows the linker to more easily delete some dead<br>
code and data by putting the guard variable and init function in the<br>
same COMDAT.<br>
<br>
One thing we have to decide is what to do about MachO. Should we omit<br>
the comdats from the IR for MachO or have llvm ignore it?<br>
<br>
Cheers,<br>
Rafael<br>
</blockquote>