[LLVMdev] Improving performance with optimization passes

Gordon Henriksen gordonhenriksen at me.com
Thu Feb 19 11:32:14 PST 2009


Hi Jon,

On 2009-02-19, at 14:00, Jon Harrop wrote:

> I'm toying with benchmarks on my HLVM and am unable to get any  
> performance improvement from optimization passes. I simply copied  
> the use of PassManager from the Kaleidoscope tutorial:
>
> Any idea what I might be doing wrong? Has anyone else got this  
> functionality giving performance boosts from OCaml?

That's a pretty barren optimization pipeline.

http://llvm.org/docs/Passes.html

See opt --help and look into what -std-compile-opts is. That's the  
usual starting point for new front ends, although it's a whole-module  
pass pipeline. But it's only a starting point, since it's tuned for  
llvm-gcc's codegen and yours will probably differ.

> Moreover, some of my programs generate a lot of redundant code (e.g.  
> alloca a struct, store a struct into it and read only one field  
> without using the rest of the struct) and this does not appear to be  
> optimized away.

I think first-class aggregates are mostly used for passing arguments  
in llvm-gcc and clang; maybe mem2reg can't see unravel the loads. Have  
you tried emitting loads and stores of the scalar elements to see if  
mem2reg can eliminate the allocas then?

— Gordon

P.S. This is not a trivial problem domain. Here's an interesting paper  
on the subject.

COLE: Compiler Optimization Level Exploration
http://users.elis.ugent.be/~leeckhou/papers/cgo08.pdf





More information about the llvm-dev mailing list