[LLVMdev] libc dependencies, code generation questions

Duncan Sands baldrick at free.fr
Thu Jun 7 05:46:09 PDT 2007


Hi Jonas,

> >> [llvm helpers such as malloc, free, memcpy, memset, fp  
> >> helpers, ... ->
> >>  taken from the standard C library?]
> >
> > I don't think LLVM spontaneously creates calls to these - it just  
> > knows how
> > to optimize them if the calls were already in the IR fed to it.
> 
> I don't really understand how it could do that. Does it simply look  
> for declarations of functions with particular signatures and inserts  
> calls to them?

it looks for functions with a certain name and signature, and supposes
that these are the standard functions with those names.
The simplify-libcalls pass does it.

> >> 4) to what extent is the front end (i.e., our compiler) responsible
> >> for code selection and optimization? In other words, should we spend
> >> a lot of time on converting if-statements to select-based predicates
> >> and things like this, or will this be done by llvm afterwards anyway?
> >> What about vectorization? Are there particular kinds of optimizations
> >> which llvm will probably never be very good at (or which are not
> >> llvm's focus in the near to middle term), and which thus should
> >> definitely be done at a higher level?
> >
> > In llvm-gcc, front-ends do very little optimization.
> 
> I actually did see gcc doing quite a bit of stuff when turning on  
> optimizations and specifying -emit-llvm. At least it moved things  
> from memory to (virtual) registers and factored common parts out of  
> switch statements.

It is LLVM that is doing these optimizations.  The LLVM optimizers
are run before the LLVM IR is output.

Ciao,

Duncan.



More information about the llvm-dev mailing list