File tree 2 files changed +39
-0
lines changed
src/cmd/compile/internal/ssa 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,19 @@ func deadcode(f *Func) {
252
252
b .Values = b .Values [:i ]
253
253
}
254
254
255
+ // Remove dead blocks from WBLoads list.
256
+ i = 0
257
+ for _ , b := range f .WBLoads {
258
+ if reachable [b .ID ] {
259
+ f .WBLoads [i ] = b
260
+ i ++
261
+ }
262
+ }
263
+ for j := i ; j < len (f .WBLoads ); j ++ {
264
+ f .WBLoads [j ] = nil
265
+ }
266
+ f .WBLoads = f .WBLoads [:i ]
267
+
255
268
// Remove unreachable blocks. Return dead blocks to allocator.
256
269
i = 0
257
270
for _ , b := range f .Blocks {
Original file line number Diff line number Diff line change
1
+ // compile
2
+
3
+ // Copyright 2018 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ // Make sure dead write barriers are handled correctly.
8
+
9
+ package main
10
+
11
+ func f (p * * int ) {
12
+ // The trick here is to eliminate the block containing the write barrier,
13
+ // but only after the write barrier branches are inserted.
14
+ // This requires some delicate code.
15
+ i := 0
16
+ var b []bool
17
+ var s string
18
+ for true {
19
+ if b [i ] {
20
+ var a []string
21
+ s = a [len (s )]
22
+ i = 0
23
+ }
24
+ * p = nil
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments