@@ -65,7 +65,7 @@ module ModSelective end
65
65
# Check that the result of direct evaluation agrees with selective evaluation
66
66
Core. eval (ModEval, ex)
67
67
isrequired = lines_required (:x , src, edges)
68
- @test sum (isrequired) == 1 + isdefined (Core, :get_binding_type ) * 3 # get_binding_type + convert + typeassert
68
+ # theere is too much diversity in lowering across Julia versions to make it useful to test `sum(isrequired)`
69
69
selective_eval_fromstart! (frame, isrequired)
70
70
@test ModSelective. x === ModEval. x
71
71
@test allmissing (ModSelective, (:y , :z , :a , :b , :k ))
@@ -128,6 +128,23 @@ module ModSelective end
128
128
Core. eval (ModEval, ex)
129
129
@test ModSelective. a3 === ModEval. a3 == 2
130
130
@test allmissing (ModSelective, (:z3 , :x3 , :y3 ))
131
+ # ensure we mark all needed control-flow for loops and conditionals,
132
+ # and don't fall-through incorrectly
133
+ ex = quote
134
+ valcf = 0
135
+ for i = 1 : 5
136
+ global valcf
137
+ if valcf < 4
138
+ valcf += 1
139
+ end
140
+ end
141
+ end
142
+ frame = Frame (ModSelective, ex)
143
+ src = frame. framecode. src
144
+ edges = CodeEdges (src)
145
+ isrequired = lines_required (:valcf , src, edges)
146
+ selective_eval_fromstart! (frame, isrequired)
147
+ @test ModSelective. valcf == 4
131
148
132
149
ex = quote
133
150
if Sys. iswindows ()
@@ -143,7 +160,7 @@ module ModSelective end
143
160
src = frame. framecode. src
144
161
edges = CodeEdges (src)
145
162
isrequired = lines_required (:c_os , src, edges)
146
- @test sum (isrequired) >= length (isrequired) - 2
163
+ @test sum (isrequired) >= length (isrequired) - 3
147
164
selective_eval_fromstart! (frame, isrequired)
148
165
Core. eval (ModEval, ex)
149
166
@test ModSelective. c_os === ModEval. c_os == Sys. iswindows ()
@@ -359,9 +376,12 @@ module ModSelective end
359
376
str = String (take! (io))
360
377
@test occursin (r" slot 1:\n preds: ssas: \[\d +, \d +\] , slots: ∅, names: ∅;\n succs: ssas: \[\d +, \d +, \d +\] , slots: ∅, names: ∅;\n assign @: \[\d +, \d +\] " , str)
361
378
@test occursin (r" succs: ssas: ∅, slots: \[\d +\] , names: ∅;" , str)
362
- @test occursin (r" s:\n preds: ssas: \[\d +\] , slots: ∅, names: ∅;\n succs: ssas: \[\d +, \d +, \d +\] , slots: ∅, names: ∅;\n assign @: \[\d , \d +\] " , str) ||
363
- occursin (r" s:\n preds: ssas: \[\d +, \d +\] , slots: ∅, names: ∅;\n succs: ssas: \[\d +, \d +, \d +\] , slots: ∅, names: ∅;\n assign @: \[\d , \d +\] " , str) # with global var inference
364
- if Base. VERSION < v " 1.8" # changed by global var inference
379
+ # Some of these differ due to changes by Julia version in global var inference
380
+ if Base. VERSION < v " 1.10"
381
+ @test occursin (r" s:\n preds: ssas: \[\d +\] , slots: ∅, names: ∅;\n succs: ssas: \[\d +, \d +, \d +\] , slots: ∅, names: ∅;\n assign @: \[\d , \d +\] " , str) ||
382
+ occursin (r" s:\n preds: ssas: \[\d +, \d +\] , slots: ∅, names: ∅;\n succs: ssas: \[\d +, \d +, \d +\] , slots: ∅, names: ∅;\n assign @: \[\d , \d +\] " , str) # with global var inference
383
+ end
384
+ if Base. VERSION < v " 1.8"
365
385
@test occursin (r" \d + preds: ssas: \[\d +\] , slots: ∅, names: \[ :s\] ;\n\d + succs: ssas: ∅, slots: ∅, names: \[ :s\] ;" , str)
366
386
end
367
387
LoweredCodeUtils. print_with_code (io, src, cl)
@@ -380,17 +400,21 @@ module ModSelective end
380
400
edges = CodeEdges (src)
381
401
show (io, edges)
382
402
str = String (take! (io))
383
- @test occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +\] , and used by \[\d +, \d +, \d +\] " , str) ||
384
- occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +, \d +\] , and used by \[\d +, \d +, \d +\] " , str) # global var inference
403
+ if Base. VERSION < v " 1.10"
404
+ @test occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +\] , and used by \[\d +, \d +, \d +\] " , str) ||
405
+ occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +, \d +\] , and used by \[\d +, \d +, \d +\] " , str) # global var inference
406
+ end
385
407
if Base. VERSION < v " 1.9"
386
408
@test (count (occursin (" statement $i depends on [1, $(i- 1 ) , $(i+ 1 ) ] and is used by [1, $(i+ 1 ) ]" , str) for i = 1 : length (src. code)) == 1 ) ||
387
409
(count (occursin (" statement $i depends on [4, $(i- 1 ) , $(i+ 4 ) ] and is used by [$(i+ 2 ) ]" , str) for i = 1 : length (src. code)) == 1 )
388
410
end
389
411
LoweredCodeUtils. print_with_code (io, src, edges)
390
412
str = String (take! (io))
391
413
if isdefined (Base. IRShow, :show_ir_stmt )
392
- @test occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +\] , and used by \[\d +, \d +, \d +\] " , str) ||
393
- occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +, \d +\] , and used by \[\d +, \d +, \d +\] " , str)
414
+ if Base. VERSION < v " 1.10"
415
+ @test occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +\] , and used by \[\d +, \d +, \d +\] " , str) ||
416
+ occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +, \d +\] , and used by \[\d +, \d +, \d +\] " , str)
417
+ end
394
418
if Base. VERSION < v " 1.9"
395
419
@test (count (occursin (" preds: [1, $(i- 1 ) , $(i+ 1 ) ], succs: [1, $(i+ 1 ) ]" , str) for i = 1 : length (src. code)) == 1 ) ||
396
420
(count (occursin (" preds: [4, $(i- 1 ) , $(i+ 4 ) ], succs: [$(i+ 2 ) ]" , str) for i = 1 : length (src. code)) == 1 ) # global var inference
@@ -404,8 +428,10 @@ module ModSelective end
404
428
LoweredCodeUtils. print_with_code (io, frame, edges)
405
429
str = String (take! (io))
406
430
if isdefined (Base. IRShow, :show_ir_stmt )
407
- @test occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +\] , and used by \[\d +, \d +, \d +\] " , str) ||
408
- occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d , \d +\] , and used by \[\d +, \d +, \d +\] " , str) # global var inference
431
+ if Base. VERSION < v " 1.10"
432
+ @test occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d +\] , and used by \[\d +, \d +, \d +\] " , str) ||
433
+ occursin (r" s: assigned on \[\d , \d +\] , depends on \[\d , \d +\] , and used by \[\d +, \d +, \d +\] " , str) # global var inference
434
+ end
409
435
if Base. VERSION < v " 1.9"
410
436
@test (count (occursin (" preds: [1, $(i- 1 ) , $(i+ 1 ) ], succs: [1, $(i+ 1 ) ]" , str) for i = 1 : length (src. code)) == 1 ) ||
411
437
(count (occursin (" preds: [4, $(i- 1 ) , $(i+ 4 ) ], succs: [$(i+ 2 ) ]" , str) for i = 1 : length (src. code)) == 1 ) # global var inference
0 commit comments