[LLVMdev] Convert C variable to LLVM IR Variable

ChiaLun h3355626 at msn.com
Tue Mar 5 00:21:53 PST 2013

Hi everyone,

  I am doing some work with LLVM IR, I need to use LLVM IR to do operation
on C variables.

Code emission is done by LLVM JIT.

That variable is C thread local , for example

__thread int* gvar;

I think some methods to convert that variable to LLVM IR, 

(1) use external function

I know LLVM IR is able to call an external function, so I can write codes
that look like:

int* load()
  return gvar;

%x = call load(); // LLVM IR

so gvar is converted to %x

This method takes a lot of work and slow down the performance.

Method 2

use LLVM InlineAsm to load that gvar 
so It may look like
%x = call InlineAsm(... );

but I am not really sure how to write LLVM InlineAsm.

The reason why I take such indirect method is that as I know, JIT is not
able to

do with LLVM GlobalVariable with ThreadLocal type.

I would be grateful to you for any idea on handling this problem

Have A Nice Day

Chia Lun Liu

View this message in context: http://llvm.1065342.n5.nabble.com/Convert-C-variable-to-LLVM-IR-Variable-tp55680.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.

More information about the llvm-dev mailing list