[LLVMdev] Cloning Functions

David Greene dag at cray.com
Wed Jul 9 11:49:10 PDT 2008


On Wednesday 09 July 2008 13:24, Devang Patel wrote:

> Is it possible to explain intended use of original unoptimized version ?

bugpoint.  I want to run it on the IR produced by our frontend.  This will 
help us generate new LLVM tests we can send upstream.  We've fixed
bugs that aren't caught by the upstream tests and it would be nice to capture
the problem and make the test available to everyone.

> You do not need to optimize LLVM IR before processing next function.

You do if the functions you compile are mega-humongous.

> If your compiler works like
>
> 	for each function
> 		generate_ir
> 		optimize

Yep.

> then it seems you're doing
>
> 	for each function
> 		generate_ir
> 		convert_to_llvm_ir
> 		optimize_llvm_ir

Yep.

> If you're doing this then you may try
>
> 	for each function
> 		generate_ir
> 		convert_to_llvm_ir
> 	optimize_llvm_ir_module

We in fact did used to do it this way.  Then we ran out of memory.

And there are other issues to.  We'd added things in our copy of LLVM
that looks to our middle-end  for various bits of information.  Some of that
information goes away after we get each function so delaying optimization
means we don't have all of the useful information we'd like.

And BTW, there are many things we had to fix in LLVM to allow us to do
this.  It seems LLVM keeps around a lot of global state that needs to be
reset if you do function-at-a-time processing.  I'm hoping to send these
fixes back upstream as soon as I deal with the red tape that's recently
been put in place here.

> Now, you have access to un-optimized functions before you do
> optimize_llvm_ir_module. Would that work ?

It will work for this particular code I'm looking at but in general it
won't.  And I'm loathe to change how our compiler flow works just
for this.  It's one more difference we'd have to deal with when tracking
down bugs.

                                                     -Dave



More information about the llvm-dev mailing list