@@ -916,8 +916,11 @@ func FDumpList(w io.Writer, s string, list Nodes) {
916
916
}
917
917
918
918
// indent prints indentation to w.
919
- func indent (w io.Writer , depth int ) {
919
+ func indent (w io.Writer , depth int , counter int64 ) {
920
920
fmt .Fprint (w , "\n " )
921
+ if base .Flag .BbPgoProfile {
922
+ fmt .Fprintf (w , "%d " , counter )
923
+ }
921
924
for i := 0 ; i < depth ; i ++ {
922
925
fmt .Fprint (w , ". " )
923
926
}
@@ -1049,7 +1052,7 @@ func dumpNodeHeader(w io.Writer, n Node) {
1049
1052
}
1050
1053
1051
1054
func dumpNode (w io.Writer , n Node , depth int ) {
1052
- indent (w , depth )
1055
+ indent (w , depth , n . Counter () )
1053
1056
if depth > 40 {
1054
1057
fmt .Fprint (w , "..." )
1055
1058
return
@@ -1063,7 +1066,7 @@ func dumpNode(w io.Writer, n Node, depth int) {
1063
1066
if len (n .Init ()) != 0 {
1064
1067
fmt .Fprintf (w , "%+v-init" , n .Op ())
1065
1068
dumpNodes (w , n .Init (), depth + 1 )
1066
- indent (w , depth )
1069
+ indent (w , depth , n . Counter () )
1067
1070
}
1068
1071
1069
1072
switch n .Op () {
@@ -1116,21 +1119,21 @@ func dumpNode(w io.Writer, n Node, depth int) {
1116
1119
dumpNodeHeader (w , n )
1117
1120
fn := n
1118
1121
if len (fn .Dcl ) > 0 {
1119
- indent (w , depth )
1122
+ indent (w , depth , n . Counter () )
1120
1123
fmt .Fprintf (w , "%+v-Dcl" , n .Op ())
1121
1124
for _ , dcl := range n .Dcl {
1122
1125
dumpNode (w , dcl , depth + 1 )
1123
1126
}
1124
1127
}
1125
1128
if len (fn .ClosureVars ) > 0 {
1126
- indent (w , depth )
1129
+ indent (w , depth , n . Counter () )
1127
1130
fmt .Fprintf (w , "%+v-ClosureVars" , n .Op ())
1128
1131
for _ , cv := range fn .ClosureVars {
1129
1132
dumpNode (w , cv , depth + 1 )
1130
1133
}
1131
1134
}
1132
1135
if len (fn .Body ) > 0 {
1133
- indent (w , depth )
1136
+ indent (w , depth , n . Counter () )
1134
1137
fmt .Fprintf (w , "%+v-body" , n .Op ())
1135
1138
dumpNodes (w , fn .Body , depth + 1 )
1136
1139
}
@@ -1164,7 +1167,7 @@ func dumpNode(w io.Writer, n Node, depth int) {
1164
1167
switch val := vf .Interface ().(type ) {
1165
1168
case Node :
1166
1169
if name != "" {
1167
- indent (w , depth )
1170
+ indent (w , depth , n . Counter () )
1168
1171
fmt .Fprintf (w , "%+v-%s" , n .Op (), name )
1169
1172
}
1170
1173
dumpNode (w , val , depth + 1 )
@@ -1173,7 +1176,11 @@ func dumpNode(w io.Writer, n Node, depth int) {
1173
1176
continue
1174
1177
}
1175
1178
if name != "" {
1176
- indent (w , depth )
1179
+ c := n .Counter ()
1180
+ if len (val ) > 0 {
1181
+ c = val [0 ].Counter ()
1182
+ }
1183
+ indent (w , depth , c )
1177
1184
fmt .Fprintf (w , "%+v-%s" , n .Op (), name )
1178
1185
}
1179
1186
dumpNodes (w , val , depth + 1 )
@@ -1183,7 +1190,7 @@ func dumpNode(w io.Writer, n Node, depth int) {
1183
1190
continue
1184
1191
}
1185
1192
if name != "" {
1186
- indent (w , depth )
1193
+ indent (w , depth , n . Counter () )
1187
1194
fmt .Fprintf (w , "%+v-%s" , n .Op (), name )
1188
1195
}
1189
1196
for i , n := 0 , vf .Len (); i < n ; i ++ {
0 commit comments