rheostat2718 / unladen-swallow

Automatically exported from code.google.com/p/unladen-swallow
Other
0 stars 0 forks source link

Simple functions are way bigger than they need to be. Fix that. #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
We currently know of a couple inefficiencies:

1. Because we always load the stack pointer, LLVM can't optimize away the
unwind loop, even in simple functions that, say, return once from the outer
scope. For non-generators, we can do better.
2. The block stack is stored in the frame, which again prevents LLVM from
optimizing away most of the unwind block.

This issue will hold a summary of this kind of issue, but we may split it
up when we get around to optimizing these things.

Original issue reported on code.google.com by jyass...@gmail.com on 21 Apr 2009 at 10:01

GoogleCodeExporter commented 9 years ago

Original comment by collinw on 27 May 2009 at 9:44

GoogleCodeExporter commented 9 years ago

Original comment by collinw on 27 May 2009 at 11:08

GoogleCodeExporter commented 9 years ago
As of r655, LLVM's analyzers now have access to the block stack.

With this patch, the empty function shrinks from 168 lines of LLVM assembly to 
118, 
and 'def foo(a): return 1+a' shrinks from 294 to 201.

Original comment by collinw on 18 Jun 2009 at 8:28

GoogleCodeExporter commented 9 years ago
r663 makes the AST->bytecode compiler omit 
SETUP_LOOP/POP_BLOCK/BREAK_LOOP instructions in some cases when they're not 
needed. This is currently a function-wide analysis, and could/should be made 
more 
powerful to analyze individual loops.

For a simple function

def foo():
    for x in range(3):
        bar(x)

this patch reduces the number of non-blank LLVM IR lines from 508 to 350.

Original comment by collinw on 21 Jun 2009 at 2:49