r185381 - Simplify linkage code for static local vars.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Jul 3 07:34:17 PDT 2013

>  namespace test17 {
> -  // CHECK-DAG: @_ZZN6test173fooILi42EEEPivE3bar = weak_odr
> +  // CHECK-DAG: @_ZZN6test173fooILi42EEEPivE3bar = linkonce_odr
>    // CHECK-DAG: define weak_odr i32* @_ZN6test173fooILi42EEEPiv(
>    template<int I>
>    int *foo() {


I was about to reply saying that this change was wrong for explicit
templates instantiations, but it is actually correct:

* When we have a definition, the function is emitted as weak_odr, the
static variable as linkonce_odr, so the variable may be discarded.

* When we have a declaration, the function is declare, and the
variable is not even mentioned, so it is OK if it is discarded in the
other translation unit.


More information about the cfe-commits mailing list