JuliaLang/julia — pull request #6435 by vtjnash (2014-04-06 06:42:52+00:00)
Title: fix #6415

@JeffBezanson please review, to make sure i didn't make a logic errors. it passes all tests even if I increase the inline_worthy threshold

this makes the inline pass smarter, so it can avoid making local variables when all previous expressions are effect_free. it also improves effect_free to handle a few more functions

it is still not doing as well as it should because of the following case: effect_free considers the body of the following function to not be effect_free
```julia
f(a) = 2*6
```

e.g. effect_free on the following expression returns false:
```
Expr
head: Symbol return
args: Array(Any,(1,))
1: Expr
head: Symbol call
args: Array(Any,(3,))
1: Symbol box
2: Symbol Int64
3: Expr
head: Symbol call
args: Array(Any,(3,))
1: Symbol mul_int
2: SymbolNode
name: Symbol x
typ: Int64
3: SymbolNode
name: Symbol y
typ: Int64
typ: Any
typ: Int64
typ: Any
```

a minimal failure case that demonstrates this issue is:
```julia
julia> f(a) = 2*a[2]
f (generic function with 1 method)

julia> code_typed(f,(Array{Int,1},))
1-element Array{Any,1}:
:($(Expr(:lambda, {:a}, {{:_var0},{{:a,Array{Int64,1},0},{:_var0,Int64,18}},{}}, :(begin # none, line 1:
_var0 = arrayref(a::Array{Int64,1},2)::Int64
return top(box)(Int64,top(mul_int)(2,_var0::Int64))::Int64
end::Int64))))
```