thread1

help

Click on a value or block to toggle highlighting of that value/block and its uses. (Values and blocks are highlighted by ID, and IDs of dead items may be reused, so not all highlights necessarily correspond to the clicked item.)

Faded out values and blocks are dead code that has not been eliminated.

Values printed in italics have a dependency cycle.

CFG: Dashed edge is for unlikely branches. Blue color is for backward edges. Edge with a dot means that this edge follows the order in which blocks were laidout.

sources

 
 
13
14
15
16
17
 
/Users/fanlv/Desktop/go_compiler_test/demo2.go
func thread1() {
for flag {
counter++
}
}

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

  • 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
  • Plainb2 (14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v6 (14) = Load <bool> v4 v5
  • If v6b3 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
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (14)
  • b5: ← b2
    • v14 (17) = Copy <mem> v5
  • Ret v14

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
  • Plainb2 (+14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v6 (+14) = Load <bool> v4 v5
  • If v6b3 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
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (+14)
  • b5: ← b2
    • v14 (17) = Copy <mem> v5
  • Ret v5 (14)

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
  • Plainb2 (+14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v6 (+14) = Load <bool> v4 v5
  • If v6b3 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
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (+14)
  • b5: ← b2
  • Ret v5 (14)

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>
  • Plainb2 (+14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v6 (+14) = Load <bool> v4 v5
  • If v6b3 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
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (+14)
  • b5: ← b2
  • Ret v5 (14)

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
  • Plainb2 (+14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v6 (+14) = Load <bool> v4 v5
  • If v6b3 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
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (+14)
  • b5: ← b2
  • Ret v5 (14)

generic deadcode [2331 ns]

writebarrier [23303 ns]

lower [2358610 ns]

  • b1:
    • v1 (?) = InitMem <mem>
    • v3 (?) = SB <uintptr>
  • Plainb2 (+14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v8 (+14) = CMPBconstload <flags> {"".flag} [val=0,off=0] v3 v5
  • NE v8b3 b5 (likely) (14)
  • b3: ← b2
    • v13 (+15) = ADDQconstmodify <mem> {"".counter} [val=1,off=0] v3 v5
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (+14)
  • b5: ← b2
  • Ret v5 (14)

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> : SB
  • Plainb2 (+14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v8 (+14) = CMPBconstload <flags> {"".flag} [val=0,off=0] v3 v5
  • NE v8b3 b5 (likely) (14)
  • b3: ← b2
    • v13 (+15) = ADDQconstmodify <mem> {"".counter} [val=1,off=0] v3 v5
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (+14)
  • b5: ← b2
  • Ret v5 (14)

stackframe [957 ns]

  • b1:
    • v1 (?) = InitMem <mem>
    • v3 (?) = SB <uintptr> : SB
  • Plainb2 (+14)
  • b2: ← b1 b4
    • v5 (14) = Phi <mem> v1 v13
    • v8 (+14) = CMPBconstload <flags> {"".flag} [val=0,off=0] v3 v5
  • NE v8b3 b5 (likely) (14)
  • b3: ← b2
    • v13 (+15) = ADDQconstmodify <mem> {"".counter} [val=1,off=0] v3 v5
  • Plainb4 (15)
  • b4: ← b3
  • Plainb2 (+14)
  • b5: ← b2
  • Ret v5 (14)

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