[LLVMdev] php crash

Xi Wang xi.wang at gmail.com
Fri Apr 3 12:23:16 PDT 2009


I tried the version you used, too.  the resulting executable was still broken.

I guess the reason is due to fastcall on function pointers, which
Clang does not recognize.  Consider the following snippet.

#include <stdio.h>

void __attribute__((fastcall)) f(int i)
{
    printf("%d\n", i);
}

typedef void (*__attribute__((fastcall)) f_t)(int i);
//typedef void __attribute__((fastcall)) (*f_t)(int i);

int main()
{
    f(42);
    f_t fp = f;
    fp(42);
}

Clang does not catch the attribute on f_t; instead it produces a
warning "'fastcall' attribute only applies to function types".  so the
function pointer might be miscompiled.

stdcall should cause the similar problem as well.

On x64 there is no use of fastcall or stdcall.  so Clang produces a
correct php executable.

- xi

On Fri, Apr 3, 2009 at 1:20 PM, Anders Johnsen <skabet at gmail.com> wrote:
> What version of clang are you using? It could be a regression between
> head and the version I used. (some days old)
>
> - Anders



More information about the llvm-dev mailing list