[LLVMdev] weird function

Le Anh Quang anhquangbk at googlemail.com
Thu Jul 24 10:13:33 PDT 2008


 Thank Duncan,
 what I actually want, is to implement a simple processor simulator, which
can execute LLVM bitcode. So it must deal with the virtual LLVM instruction
set.
 As I compiled a C or C++ program using llvm-gcc or llvm-g++, I have a
bitcode file. If a C++ library is used, some functions will be declared
inside it, but not defined there (like the @_Znwj). Is it possible to create
LLVM IR with all libraries defined inside (or linked with another bitcode
libraries) ?
Maybe it looks like that:

....
%tmp183 = tail call i32 (i8*, ...)* @printf( i8* getelementptr ([13 x i8]*
@.str1, i32 0, i32 0), i32 %tmp182 ) nounwind 

tail call void @_ZdlPv( i8* %tmp432.i312 ) nounwind 
....
define i32 @printf(i8*, ...) nounwind {
... // LLVM instructions
}
define i8* @_Znwj(i32) {
... // LLVM instructions
}

Thank for any advice
Quang

-----Ursprüngliche Nachricht-----
Von: Duncan Sands [mailto:baldrick at free.fr] 
Gesendet: Donnerstag, 24. Juli 2008 17:49
An: llvmdev at cs.uiuc.edu
Cc: Le Anh Quang
Betreff: Re: [LLVMdev] weird function

Hi,

>  thank for your answer. Is there any document/tutorial about linking
> bytecode file with libstdc++ avaiable ?

first you need to compile the bitcode to assembler using llc.
For example:
  llc bitcode.bc
This produces bitcode.s.  Turn this into a executable using:
  llvm-g++ -o bitcode bitcode.s
or
  g++ -o bitcode bitcode.s
It doesn't matter which g++ you use here.  Using g++ means
that your program will automatically be linked with libstdc++.

I hope this helps,

Duncan.





More information about the llvm-dev mailing list