mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
transform: do not special-case zero or one implementations of a method call
This is a common case, but it also complicates the code. Removing this special case does have a negative effect on code size in rare cases, but I don't think it's worth keeping around (and possibly causing bugs) for such uncommon cases. This should not result in functional changes, although the output (as stated above) sometimes changes a little bit.
This commit is contained in:
committed by
Ron Evans
parent
c72f9eb08c
commit
1570adac1c
Vendored
+16
-2
@@ -47,8 +47,8 @@ typeswitch.notUnmatched: ; preds = %0
|
||||
br i1 %typeassert.ok, label %typeswitch.Doubler, label %typeswitch.notDoubler
|
||||
|
||||
typeswitch.Doubler: ; preds = %typeswitch.notUnmatched
|
||||
%doubler.result = call i32 @"(Number).Double$invoke"(i8* %value, i8* null)
|
||||
call void @runtime.printint32(i32 %doubler.result)
|
||||
%1 = call i32 @"(Doubler).Double"(i8* %value, i8* null, i32 %typecode, i8* null)
|
||||
call void @runtime.printint32(i32 %1)
|
||||
ret void
|
||||
|
||||
typeswitch.notDoubler: ; preds = %typeswitch.notUnmatched
|
||||
@@ -76,6 +76,20 @@ define i32 @"(Number).Double$invoke"(i8* %receiverPtr, i8* %parentHandle) {
|
||||
ret i32 %ret
|
||||
}
|
||||
|
||||
define internal i32 @"(Doubler).Double"(i8* %0, i8* %1, i32 %actualType, i8* %parentHandle) unnamed_addr {
|
||||
entry:
|
||||
switch i32 %actualType, label %default [
|
||||
i32 68, label %"reflect/types.type:named:Number"
|
||||
]
|
||||
|
||||
default: ; preds = %entry
|
||||
unreachable
|
||||
|
||||
"reflect/types.type:named:Number": ; preds = %entry
|
||||
%2 = call i32 @"(Number).Double$invoke"(i8* %0, i8* %1)
|
||||
ret i32 %2
|
||||
}
|
||||
|
||||
define internal i1 @"Doubler$typeassert"(i32 %actualType) unnamed_addr {
|
||||
entry:
|
||||
switch i32 %actualType, label %else [
|
||||
|
||||
Reference in New Issue
Block a user