[cfe-dev] Strange character around function declared with "asm"

Eric Christopher echristo at apple.com
Thu Dec 2 22:43:01 PST 2010


On Dec 2, 2010, at 8:49 PM, Lorenzo De Carli wrote:

> Hi everyone,
> 
> I am trying to instruct clang to generate llvm intrinsics in place of
> certain function calls, and to do so I am using the "asm" tag. For
> example:
> 
> void MyFunc(int a, int b) asm("llvm.myfunc");
> 
> void DoSomething() {
>  int x = 1;
>  int y = 2;
> 
>  MyFunc(x, y);
> }
> 
> However, if I try to compile the above function with "clang -emit-llvm
> -S test.c -o test.s" I obtain:
> 
> define void @DoSomething() nounwind {
>  %x = alloca i32, align 4
>  %y = alloca i32, align 4
>  store i32 1, i32* %x, align 4
>  store i32 2, i32* %y, align 4
>  %1 = load i32* %x, align 4
>  %2 = load i32* %y, align 4
>  call void @"\01llvm.myfunc"(i32 %1, i32 %2)
>  ret void
> }
> 
> declare void @"\01llvm.myfunc"(i32, i32)
> 
> Is there a reason for the quotation marks (") and the \01 before the
> intrinsic call? I tried to get the same assembly from llvm-gcc, and in
> that case there are no quotation marks or other artefacts.

Apparently clang is mangling it this way on purpose as far as I can
tell... I'm not really sure why though.

John?

-eric



More information about the cfe-dev mailing list