dropbox/pyston — pull request #184 by undingen (2014-10-06 20:19:18+00:00)
Title: Some small changes to simplify the generated IR.

+ mark the alloc routines as no throw and no alias (=attribute(malloc), noexcept).
This removes a lot of invokes in the IR and marks every alloc call as noalias. (While I felt somewhat frightened by the malloc attribute AFAIK the generated IR looks reasonable.)
+ inline the trivial Box constructor
+ fix dead allocs pass: we will now remove the useless list creation inside f2 in speculation_test.py

While this currently does not show much speed change it at least makes the generated IR much easier to read. And theoretically should generate code faster by reducing the amount of exception handling tables and provide better optimization opportunities by having more functions marked as noalias.

For example this changes the IR of createList() from:
```LLVM
; Function Attrs: uwtable
define %"class.pyston::Box"* @createList() #0 {
_ZN6pyston14PythonGCObjectnwEm.exit:
%0 = tail call %"struct.pyston::gc::GCAllocation"* @_ZN6pyston2gc4Heap10allocSmallEmi(%"class.pyston::gc::Heap"* @_ZN6pyst on2gc11global_heapE, i64 48, i32 2)
%1 = getelementptr inbounds %"struct.pyston::gc::GCAllocation"* %0, i64 0, i32 0
%2 = load i64* %1, align 4
%3 = and i64 %2, -65536
%4 = or i64 %3, 256
store i64 %4, i64* %1, align 4
%5 = getelementptr inbounds %"struct.pyston::gc::GCAllocation"* %0, i64 0, i32 1, i64 0
%6 = bitcast i8* %5 to %"class.pyston::BoxedClass"**
store %"class.pyston::BoxedClass"* null, %"class.pyston::BoxedClass"** %6, align 8, !tbaa !7
%7 = bitcast i8* %5 to %"class.pyston::Box"*
%8 = load %"class.pyston::BoxedClass"** @list_cls, align 8, !tbaa !10
invoke void @_ZN6pyston3BoxC2EPNS_10BoxedClassE(%"class.pyston::Box"* %7, %"class.pyston::BoxedClass"* %8)
to label %9 unwind label %11

; :9 ; preds = %_ZN6pyston14PythonGCObjectnwEm.exit
%10 = getelementptr inbounds %"struct.pyston::gc::GCAllocation"* %0, i64 0, i32 1, i64 8
tail call void @llvm.memset.p0i8.i64(i8* %10, i8 0, i64 16, i32 8, i1 false)
ret %"class.pyston::Box"* %7

; :11 ; preds = %_ZN6pyston14PythonGCObjectnwEm.exit
%12 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
cleanup
tail call void @_ZN6pyston14PythonGCObjectdlEPv(i8* %5) #6
unreachable
}
```
to:
```LLVM
; Function Attrs: nounwind uwtable
define noalias %"class.pyston::Box"* @createList() #0 {
_ZN6pyston14PythonGCObjectnwEm.exit:
%0 = tail call noalias %"struct.pyston::gc::GCAllocation"* @_ZN6pyston2gc4Heap10allocSmallEmi(%"class.pyston::gc::Heap"* @ _ZN6pyston2gc11global_heapE, i64 48, i32 2) #6
%1 = getelementptr inbounds %"struct.pyston::gc::GCAllocation"* %0, i64 0, i32 0
%2 = load i64* %1, align 4
%3 = and i64 %2, -65536
%4 = or i64 %3, 256
store i64 %4, i64* %1, align 4
%5 = getelementptr inbounds %"struct.pyston::gc::GCAllocation"* %0, i64 0, i32 1, i64 0
%6 = bitcast i8* %5 to %"class.pyston::BoxedClass"**
%7 = load %"class.pyston::BoxedClass"** @list_cls, align 8, !tbaa !7
store %"class.pyston::BoxedClass"* %7, %"class.pyston::BoxedClass"** %6, align 8, !tbaa !9
%8 = getelementptr inbounds %"struct.pyston::gc::GCAllocation"* %0, i64 0, i32 1, i64 8
tail call void @llvm.memset.p0i8.i64(i8* %8, i8 0, i64 16, i32 8, i1 false) #6
%9 = bitcast i8* %5 to %"class.pyston::Box"*
ret %"class.pyston::Box"* %9
}
```