[cfe-commits] r47850 - /cfe/trunk/Headers/mmintrin.h

Eli Friedman eli.friedman at gmail.com
Tue Mar 4 14:44:05 PST 2008


On Tue, Mar 4, 2008 at 1:39 PM, Chris Lattner <clattner at apple.com> wrote:
> On Mar 3, 2008, at 7:41 PM, Eli Friedman wrote:
>  Wouldn't something like this be fine:
>
>  __inline __m64 __attribute__((__always_inline__, __nodebug__))
>  _mm_cvtsi32_si64 (int __i) { ... }
>
>  ?  Using __inline covers C90, this has both attributes, and isn't
>  static.

Suppose someone does something like the following:

Module A:
#include <mmintrin.h>
typedef __m64 int2m64func(int);
__m64 x(int2m64func*);
__m64 y() {return x(_mm_cvtsi32_si64);}

int main(void) {y(); return 0;}

Module B:
#include <mmintrin.h>
typedef __m64 int2m64func(int);
__m64 x(int2m64func* f) {return f(1);}

Per C99 6.7.4 (ignoring the attributes), the call to _mm_cvtsi32_si64
in Module B is not allowed to call the  the definition of
_mm_cvtsi32_si64 in mmintrin.h, and therefore, unless there is a
definition elsewhere, should cause a link error if it isn't defined
elsewhere.

Hmm, looking at it again, "extern inline __attribute__((weak))" isn't
quite right... we really want something like "extern inline
__attribute__((linkonce))".

-Eli



More information about the cfe-commits mailing list