mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
compiler: do not emit nil checks for loading closure variables
Closure variables are allocated in a parent function and are thus never nil. Don't do a nil check before reading or modifying the value. This commit results in a slight reduction in code size in some test cases: calls.go, channel.go, goroutines.go, json.go, sort.go - presumably wherever closures are used.
This commit is contained in:
committed by
Ron Evans
parent
ec325c0643
commit
3edcdb5f0d
-10
@@ -86,14 +86,6 @@ entry:
|
||||
|
||||
define hidden void @"main.closureFunctionGoroutine$1"(i32 %x, i8* %context, i8* %parentHandle) unnamed_addr {
|
||||
entry:
|
||||
%0 = icmp eq i8* %context, null
|
||||
br i1 %0, label %store.throw, label %store.next
|
||||
|
||||
store.throw: ; preds = %entry
|
||||
call void @runtime.nilPanic(i8* undef, i8* null)
|
||||
unreachable
|
||||
|
||||
store.next: ; preds = %entry
|
||||
%unpack.ptr = bitcast i8* %context to i32*
|
||||
store i32 7, i32* %unpack.ptr, align 4
|
||||
ret void
|
||||
@@ -112,8 +104,6 @@ entry:
|
||||
|
||||
declare void @runtime.printint32(i32, i8*, i8*)
|
||||
|
||||
declare void @runtime.nilPanic(i8*, i8*)
|
||||
|
||||
define hidden void @main.funcGoroutine(i8* %fn.context, void (i32, i8*, i8*)* %fn.funcptr, i8* %context, i8* %parentHandle) unnamed_addr {
|
||||
entry:
|
||||
%0 = call i8* @runtime.alloc(i32 12, i8* undef, i8* null)
|
||||
|
||||
Vendored
-10
@@ -62,14 +62,6 @@ entry:
|
||||
|
||||
define hidden void @"main.closureFunctionGoroutine$1"(i32 %x, i8* %context, i8* %parentHandle) unnamed_addr {
|
||||
entry:
|
||||
%0 = icmp eq i8* %context, null
|
||||
br i1 %0, label %store.throw, label %store.next
|
||||
|
||||
store.throw: ; preds = %entry
|
||||
call void @runtime.nilPanic(i8* undef, i8* null)
|
||||
unreachable
|
||||
|
||||
store.next: ; preds = %entry
|
||||
%unpack.ptr = bitcast i8* %context to i32*
|
||||
store i32 7, i32* %unpack.ptr, align 4
|
||||
ret void
|
||||
@@ -77,8 +69,6 @@ store.next: ; preds = %entry
|
||||
|
||||
declare void @runtime.printint32(i32, i8*, i8*)
|
||||
|
||||
declare void @runtime.nilPanic(i8*, i8*)
|
||||
|
||||
define hidden void @main.funcGoroutine(i8* %fn.context, i32 %fn.funcptr, i8* %context, i8* %parentHandle) unnamed_addr {
|
||||
entry:
|
||||
%0 = call i32 @runtime.getFuncPtr(i8* %fn.context, i32 %fn.funcptr, i8* nonnull @"reflect/types.funcid:func:{basic:int}{}", i8* undef, i8* null)
|
||||
|
||||
Reference in New Issue
Block a user