[LLVMdev] Convert C variable to LLVM IR Variable

ChiaLun h3355626 at msn.com
Tue Mar 5 08:56:49 PST 2013


Hi Ciao, Duncan

   I had tested your method before but fail. I did it  today but fail again.


I write a simple c program

#include<stdio.h>

__thread int g[128];

int main()
{
        int i;
        for(i = 0 ; i< 128 ; i++)
        {       g[i] = 2*i;
          printf("%d\n",g[i]);
        }
        return 0;
}

-------------
I turn it to LLVM IR by
clang -S -emit-llvm $file
then use lli -use-mcjit $file.s

the following is my output



 :~/Desktop/program$ lli threadLocal.s  -use-mcjit
Cannot allocate thread local storage on this arch!
UNREACHABLE executed at
/home/bendog/Desktop/llvm-3.2.src/lib/Target/X86/X86JITInfo.cpp:585!
0  lli             0x0000000000d14acf
1  lli             0x0000000000d14fe9
2  libpthread.so.0 0x00007fae25fc9cb0
3  libc.so.6       0x00007fae25218425 gsignal + 53
4  libc.so.6       0x00007fae2521bb8b abort + 379
5  lli             0x0000000000d00fbc
6  lli             0x00000000006176ec
7  lli             0x0000000000845747
llvm::JIT::getMemoryForGV(llvm::GlobalVariable const*) + 343
8  lli             0x00000000008471ed
llvm::JIT::getOrEmitGlobalVariable(llvm::GlobalVariable const*) + 333
9  lli             0x0000000000850739
10 lli             0x000000000085222b
11 lli             0x000000000057c151
12 lli             0x0000000000cadd1f
llvm::FPPassManager::runOnFunction(llvm::Function&) + 607
13 lli             0x0000000000cb134b
llvm::FunctionPassManagerImpl::run(llvm::Function&) + 139
14 lli             0x0000000000cb14c9
llvm::FunctionPassManager::run(llvm::Function&) + 105
15 lli             0x0000000000847647
llvm::JIT::jitTheFunction(llvm::Function*, llvm::MutexGuard const&) + 39
16 lli             0x0000000000847cac
llvm::JIT::runJITOnFunctionUnlocked(llvm::Function*, llvm::MutexGuard
const&) + 28
17 lli             0x0000000000847e69
llvm::JIT::getPointerToFunction(llvm::Function*) + 265
18 lli             0x000000000050b71a main + 3210
19 libc.so.6       0x00007fae2520376d __libc_start_main + 237
20 lli             0x0000000000512d09
Stack dump:
0.	Program arguments: lli threadLocal.s -use-mcjit 
1.	Running pass 'X86 Machine Code Emitter' on function '@main'
Aborted (core dumped)


As can seen from the result, I use llvm 3.2, and my machine is x86_64 , OS :
Ubuntu 12.xx


Chia Lun Liu




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



More information about the llvm-dev mailing list