[cfe-dev] Intrinsics without builtin

Damien Vincent damien.llvm at gmail.com
Thu Mar 31 17:05:54 PDT 2011


Hi,

I got a solution to use intrinsics without the need of builtin functions from:
http://wiki.llvm.org/HowTo:_Call_LLVM_intrinsics_from_C_code

Do you know if this approach is still valid ?

The example is the following:

  extern "C" int llvm_cas(volatile int*, int, int)
asm("llvm.atomic.cmp.swap.i32");

  int foo(volatile int* add, int from, int to) {
      return llvm_cas(add, from, to);
  }

And the expected llvm output is:

  define i32 @_Z3fooPViii(i32* %add, i32 %from, i32 %to) {
  entry:
  	%0 = tail call i32 @llvm.atomic.cmp.swap.i32(i32* %add, i32 %from,
i32 %to); <i32> [#uses=1]
  	ret i32 %0
  }

  declare i32 @llvm.atomic.cmp.swap.i32(i32*, i32, i32)

However, when I compile the same code, it generates the following call:

   %call = tail call i32 @"\01llvm.atomic.cmp.swap.i32"(i32* %add, i32
%from, i32 %to) nounwind optsize

which looks to me a regular call and not a direct call to the intrinsic.

   Thank you,

  Damien
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110331/82c7e044/attachment.html>


More information about the cfe-dev mailing list