sources
sources
/Users/fanlv/Desktop/go_compiler_test/demo2.go
func thread1() {
for flag {
counter++
}
}
AST
AST buildssa-enter
buildssa-body
. FOR l(14) tc(1)
. . NAME-main.flag l(4) x(0) class(PEXTERN) tc(1) used bool
. . BLOCK l(14)
. FOR-body
. . AS l(15) tc(1) implicit(true) int
. . . NAME-main.counter l(3) x(0) class(PEXTERN) tc(1) assigned used int
. . . ADD l(15) tc(1) int
. . . . NAME-main.counter l(3) x(0) class(PEXTERN) tc(1) assigned used int
. . . . LITERAL-1 l(15) tc(1) int
buildssa-exit
start
start b1 :- v1 (?) = InitMem <mem>v2 (?) = SP <uintptr>v3 (?) = SB <uintptr>v4 (?) = Addr <*bool> {"".flag} v3 v7 (?) = Addr <*int> {"".counter} v3 v10 (?) = Const64 <int> [1]v12 (?) = Addr <*int> {"".counter} v3 Plain → b2 (14) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v6 (14) = Load <bool> v4 v5 If v6 → b3 b5 (likely) (14) b3 : ← b2 - v8 (15 ) = Copy <mem> v5 v9 (15) = Load <int> v7 v8 v11 (15) = Add64 <int> v9 v10 v13 (15) = Store <mem> {int} v12 v11 v8 Plain → b4 (15)
number lines + decompose user + opt
number lines [9249 ns] decompose user [14616 ns] opt [1273845 ns] b1 :- v1 (?) = InitMem <mem>v3 (?) = SB <uintptr>v4 (?) = Addr <*bool> {"".flag} v3 v7 (?) = Addr <*int> {"".counter} v3 v10 (?) = Const64 <int> [1]v12 (?) = Addr <*int> {"".counter} v3 Plain → b2 (+14 ) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v6 (+14 ) = Load <bool> v4 v5 If v6 → b3 b5 (likely) (14) b3 : ← b2 - v9 (+15 ) = Load <int> v7 v5 v11 (15) = Add64 <int> v9 v10 v13 (15) = Store <mem> {int} v12 v11 v5 Plain → b4 (15)
zero arg cse + opt deadcode
zero arg cse [2170 ns] opt deadcode [3203 ns] b1 :- v1 (?) = InitMem <mem>v3 (?) = SB <uintptr>v4 (?) = Addr <*bool> {"".flag} v3 v7 (?) = Addr <*int> {"".counter} v3 v10 (?) = Const64 <int> [1]v12 (?) = Addr <*int> {"".counter} v3 Plain → b2 (+14 ) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v6 (+14 ) = Load <bool> v4 v5 If v6 → b3 b5 (likely) (14) b3 : ← b2 - v9 (+15 ) = Load <int> v7 v5 v11 (15) = Add64 <int> v9 v10 v13 (15) = Store <mem> {int} v12 v11 v5 Plain → b4 (15)
gcse deadcode + decompose builtin + expand calls
gcse deadcode [2103 ns] decompose builtin [2477 ns] expand calls [148778 ns] b1 :- v1 (?) = InitMem <mem>v3 (?) = SB <uintptr>v4 (?) = Addr <*bool> {"".flag} v3 v7 (?) = Addr <*int> {"".counter} v3 v10 (?) = Const64 <int> [1]v12 (?) = Addr <*int> {"".counter} v3 v14 (14 ) = SP <uintptr>Plain → b2 (+14 ) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v6 (+14 ) = Load <bool> v4 v5 If v6 → b3 b5 (likely) (14) b3 : ← b2 - v9 (+15 ) = Load <int> v7 v5 v11 (15) = Add64 <int> v9 v10 v13 (15) = Store <mem> {int} v12 v11 v5 Plain → b4 (15)
softfloat + late opt
softfloat [249 ns] late opt [3949 ns] b1 :- v1 (?) = InitMem <mem>v3 (?) = SB <uintptr>v4 (?) = Addr <*bool> {"".flag} v3 v7 (?) = Addr <*int> {"".counter} v3 v10 (?) = Const64 <int> [1]v12 (?) = Addr <*int> {"".counter} v3 Plain → b2 (+14 ) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v6 (+14 ) = Load <bool> v4 v5 If v6 → b3 b5 (likely) (14) b3 : ← b2 - v9 (+15 ) = Load <int> v7 v5 v11 (15) = Add64 <int> v9 v10 v13 (15) = Store <mem> {int} v12 v11 v5 Plain → b4 (15)
generic deadcode + writebarrier + lower
generic deadcode [2331 ns] writebarrier [23303 ns] lower [2358610 ns] b1 :- v1 (?) = InitMem <mem>v3 (?) = SB <uintptr>Plain → b2 (+14 ) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v8 (+14 ) = CMPBconstload <flags> {"".flag} [val=0,off=0] v3 v5 NE v8 → b3 b5 (likely) (14) b3 : ← b2 - v13 (+15 ) = ADDQconstmodify <mem> {"".counter} [val=1,off=0] v3 v5 Plain → b4 (15)
tighten tuple selectors + lowered deadcode + checkLower + critical + layout + schedule + flagalloc + regalloc
tighten tuple selectors [543 ns] lowered deadcode [1841 ns] checkLower [15187 ns] critical [18019 ns] layout [17253 ns] schedule [32179 ns] flagalloc [2296 ns] regalloc [1064943 ns] b1 :- v1 (?) = InitMem <mem>v3 (?) = SB <uintptr> : SBPlain → b2 (+14 ) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v8 (+14 ) = CMPBconstload <flags> {"".flag} [val=0,off=0] v3 v5 NE v8 → b3 b5 (likely) (14) b3 : ← b2 - v13 (+15 ) = ADDQconstmodify <mem> {"".counter} [val=1,off=0] v3 v5 Plain → b4 (15)
stackframe
stackframe [957 ns] b1 :- v1 (?) = InitMem <mem>v3 (?) = SB <uintptr> : SBPlain → b2 (+14 ) b2 : ← b1 b4 - v5 (14 ) = Phi <mem> v1 v13 v8 (+14 ) = CMPBconstload <flags> {"".flag} [val=0,off=0] v3 v5 NE v8 → b3 b5 (likely) (14) b3 : ← b2 - v13 (+15 ) = ADDQconstmodify <mem> {"".counter} [val=1,off=0] v3 v5 Plain → b4 (15)
genssa
genssa # /Users/fanlv/Desktop/go_compiler_test/demo2.go 00000 (13) TEXT "".thread1(SB), ABIInternal 00001 (13) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) 00002 (13) FUNCDATA $1, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB) b1 00003 (14 ) JMP 4 v8 00004 (+14 ) CMPB "".flag(SB), $0 b2 00005 (14 ) JNE 7 b2 00006 (14 ) JMP 10 v13 00007 (+15 ) INCQ "".counter(SB) b3 00008 (15 ) JMP 9 b4 00009 (14 ) JMP 4 b5 00010 (14) RET 00011 (?) END