sources
sources
/Users/mohammed/projects/gopheradvent.com/site/content/calendar/2021/lisp-in-go/main.go
func main() {
var int_16 int16 = 0
int_16 = 6
var float_64_1 float64 = 1
var float_64_a float64 = float64(int_16)
var float_64_b = float_64_a + float_64_1
print(float_64_b)
}
AST
AST buildssa-enter
buildssa-body
. DCL tc(1) # main.go:4
. . NAME-main.int_16 esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used int16 # main.go:4
. AS tc(1) # main.go:4
. . NAME-main.int_16 esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used int16 # main.go:4
. . LITERAL-0 tc(1) int16 # main.go:4
. AS tc(1) # main.go:5
. . NAME-main.int_16 esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used int16 # main.go:4
. . LITERAL-6 tc(1) int16 # main.go:5
. DCL tc(1) # main.go:6
. . NAME-main.float_64_1 esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:6
. AS tc(1) # main.go:6
. . NAME-main.float_64_1 esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:6
. . LITERAL-1 tc(1) float64 # main.go:6
. DCL tc(1) # main.go:7
. . NAME-main.float_64_a esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:7
. AS tc(1) # main.go:7
. . NAME-main.float_64_a esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:7
. . CONV tc(1) float64 # main.go:7 float64
. . . NAME-main.int_16 esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used int16 # main.go:4
. DCL tc(1) # main.go:8
. . NAME-main.float_64_b esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:8
. AS tc(1) # main.go:8
. . NAME-main.float_64_b esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:8
. . ADD tc(1) float64 # main.go:8 float64
. . . NAME-main.float_64_a esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:7
. . . NAME-main.float_64_1 esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:6
. BLOCK tc(1) # main.go:9
. BLOCK-List
. . CALLFUNC tc(1) Use:3 Walked # main.go:9
. . . NAME-runtime.printlock tc(1) Class:PFUNC Offset:0 Used FUNC-func()
. . CALLFUNC tc(1) Use:3 Walked # main.go:9
. . . NAME-runtime.printfloat tc(1) Class:PFUNC Offset:0 Used FUNC-func(float64)
. . CALLFUNC-Args
. . . NAME-main.float_64_b esc(no) tc(1) Class:PAUTO Offset:0 OnStack Used float64 # main.go:8
. . CALLFUNC tc(1) Use:3 Walked # main.go:9
. . . NAME-runtime.printunlock tc(1) Class:PFUNC Offset:0 Used FUNC-func()
buildssa-exit
before insert phis
before insert phis b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = GetClosurePtr <*uint8>v5 (?) = Const16 <int16> [0] (int_16[int16])v6 (?) = Const16 <int16> [6] (int_16[int16])v7 (?) = Const64F <float64> [1] (float_64_1[float64])v8 (7) = SignExt16to32 <int32> v6 v9 (7) = Cvt32to64F <float64> v8 (float_64_a[float64])v10 (8) = Add64F <float64> v9 v7 (float_64_b[float64])v11 (9) = StaticLECall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticLECall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (10) = MakeResult <mem> v16 Ret v17 (10) name int_16[int16]: v5 v6 name float_64_1[float64]: v7 name float_64_a[float64]: v9 name float_64_b[float64]: v10
start + number lines + early phielim + early copyelim + early deadcode
start number lines [557340 ns] early phielim [3594 ns] early copyelim [969 ns] early deadcode [9215 ns] b1 :- v1 (?) = InitMem <mem>v6 (?) = Const16 <int16> [6] (int_16[int16])v7 (?) = Const64F <float64> [1] (float_64_1[float64])v8 (+7 ) = SignExt16to32 <int32> v6 v9 (7) = Cvt32to64F <float64> v8 (float_64_a[float64])v10 (+8 ) = Add64F <float64> v9 v7 (float_64_b[float64])v11 (+9 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticLECall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name int_16[int16]: v6 name float_64_1[float64]: v7 name float_64_a[float64]: v9 name float_64_b[float64]: v10
short circuit + decompose user + pre-opt deadcode + opt
short circuit [7692 ns] decompose user [2896 ns] pre-opt deadcode [3309 ns] opt [2439862 ns] b1 :- v1 (?) = InitMem <mem>v10 (+8 ) = Const64F <float64> [7] (float_64_b[float64])v11 (+9 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticLECall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name int_16[int16]: v6 name float_64_1[float64]: v7 name float_64_a[float64]: v9 name float_64_b[float64]: v10
zero arg cse + opt deadcode
zero arg cse [2733 ns] opt deadcode [4810 ns] b1 :- v1 (?) = InitMem <mem>v10 (+8 ) = Const64F <float64> [7] (float_64_b[float64])v11 (+9 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticLECall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name float_64_b[float64]: v10
generic cse + phiopt + gcse deadcode + nilcheckelim + prove
generic cse [38622 ns] phiopt [2911 ns] gcse deadcode [3302 ns] nilcheckelim [10143 ns] prove [14267 ns] b1 :- v1 (?) = InitMem <mem>v10 (+8 ) = Const64F <float64> [7] (float_64_b[float64])v11 (+9 ) = StaticLECall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticLECall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticLECall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 v9 (?) = Const64 <int64> [0]Ret v17 (10) name float_64_b[float64]: v10
early fuse + decompose builtin + expand calls
early fuse [3389 ns] decompose builtin [531350 ns] expand calls [270026 ns] b1 :- v1 (?) = InitMem <mem>v10 (+8 ) = Const64F <float64> [7] (float_64_b[float64])v11 (+9 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticCall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticCall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 v9 (?) = Const64 <int64> [0]v8 (?) = SB <uintptr>v7 (?) = SP <uintptr>Ret v17 (10) name float_64_b[float64]: v10
softfloat + late opt
softfloat [349 ns] late opt [4654 ns] b1 :- v1 (?) = InitMem <mem>v10 (+8 ) = Const64F <float64> [7] (float_64_b[float64])v11 (+9 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticCall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticCall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name float_64_b[float64]: v10
dead auto elim + generic deadcode + check bce + branchelim + late fuse
dead auto elim [517189 ns] generic deadcode [6149 ns] check bce [209 ns] branchelim [5270 ns] late fuse [3508 ns] b1 :- v1 (?) = InitMem <mem>v10 (+8 ) = Const64F <float64> [7] (float_64_b[float64])v11 (+9 ) = StaticCall <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = StaticCall <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = StaticCall <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 v7 (?) = Const64 <int64> [0]Ret v17 (10) name float_64_b[float64]: v10
dse + writebarrier + lower
dse [10429 ns] writebarrier [5496 ns] lower [895081 ns] b1 :- v1 (?) = InitMem <mem>v10 (+8 ) = MOVSDconst <float64> [7] (float_64_b[float64])v11 (+9 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v13 (9) = CALLstatic <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name float_64_b[float64]: v10
addressing modes + lowered deadcode for cse + lowered cse + elim unread autos + tighten tuple selectors + lowered deadcode + checkLower + late phielim + late copyelim + tighten + late deadcode + critical + phi tighten + likelyadjust + layout + schedule
addressing modes [1315 ns] lowered deadcode for cse [3729 ns] lowered cse [3138 ns] elim unread autos [374 ns] tighten tuple selectors [1344 ns] lowered deadcode [1303 ns] checkLower [350 ns] late phielim [378 ns] late copyelim [237 ns] tighten [14007 ns] late deadcode [1191 ns] critical [296 ns] phi tighten [166 ns] likelyadjust [310 ns] layout [841 ns] schedule [7955 ns] b1 :- v1 (?) = InitMem <mem>v11 (+9 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v10 (+8 ) = MOVSDconst <float64> [7] (float_64_b[float64])v13 (9) = CALLstatic <mem> {AuxCall{runtime.printfloat}} [8] v10 v12 v14 (9) = SelectN <mem> [0] v13 v15 (9) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name float_64_b[float64]: v10
late nilcheck + flagalloc + regalloc
late nilcheck [1374 ns] flagalloc [4790 ns] regalloc [585820 ns] b1 :- v1 (?) = InitMem <mem>v11 (+9 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v7 (9 ) = MOVSDconst <float64> [7] : X0v13 (9) = CALLstatic <mem> {AuxCall{runtime.printfloat}} [8] v7 v12 : >v14 (9) = SelectN <mem> [0] v13 v15 (9) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name float_64_b[float64]: v10
loop rotate + stackframe + trim
loop rotate [275 ns] stackframe [4448 ns] trim [418 ns] b1 :- v1 (?) = InitMem <mem>v11 (+9 ) = CALLstatic <mem> {AuxCall{runtime.printlock}} v1 v12 (9) = SelectN <mem> [0] v11 v7 (9 ) = MOVSDconst <float64> [7] : X0v13 (9) = CALLstatic <mem> {AuxCall{runtime.printfloat}} [8] v7 v12 : >v14 (9) = SelectN <mem> [0] v13 v15 (9) = CALLstatic <mem> {AuxCall{runtime.printunlock}} v14 v16 (9) = SelectN <mem> [0] v15 v17 (+10 ) = MakeResult <mem> v16 Ret v17 (10) name float_64_b[float64]: v10
genssa
genssa # /Users/mohammed/projects/gopheradvent.com/site/content/calendar/2021/lisp-in-go/main.go 00000 (3) TEXT "".main(SB), ABIInternal 00001 (3) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) 00002 (3) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) v11 00003 (+9 ) PCDATA $1, $0 v11 00004 (+9 ) CALL runtime.printlock(SB) v7 00005 (9 ) MOVSD $(7.0), X0 v13 00006 (9 ) CALL runtime.printfloat(SB) v15 00007 (9 ) CALL runtime.printunlock(SB) b1 00008 (10) RET 00009 (?) END