@@ -7434,6 +7434,7 @@ end
7434
7434
@test isa (Core. eval (@__MODULE__ , :(Bar31062 (()))), Bar31062)
7435
7435
@test precompile (identity, (Foo31062,))
7436
7436
7437
+ using Core: SSAValue
7437
7438
ftype_eval = Ref (0 )
7438
7439
FieldTypeA = String
7439
7440
FieldTypeE = UInt32
@@ -7457,27 +7458,41 @@ let fc = FieldConvert(1.0, [2.0], 0x3, 0x4, 0x5)
7457
7458
end
7458
7459
@test ftype_eval[] == 1
7459
7460
let code = code_lowered (FieldConvert)[1 ]. code
7460
- local fc_global_ssa, sp1_ssa, apply_type_ssa, field_type_ssa,
7461
- field_type2_ssa, field_type4_ssa, field_type5_ssa,
7462
- slot_read_1, slot_read_2, slot_read_3, slot_read_4,
7463
- new_ssa
7464
- @test code[(fc_global_ssa = 1 ;)] == GlobalRef (@__MODULE__ , :FieldConvert )
7465
- @test code[(sp1_ssa = 2 ;)] == Expr (:static_parameter , 1 )
7466
- @test code[(apply_type_ssa = 3 ;)] == Expr (:call , GlobalRef (Core, :apply_type ), Core. SSAValue (fc_global_ssa), GlobalRef (@__MODULE__ , :FieldTypeA ), Core. SSAValue (sp1_ssa))
7467
- @test code[(field_type_ssa = 4 ;)] == Expr (:call , GlobalRef (Core, :fieldtype ), Core. SSAValue (apply_type_ssa), 1 )
7468
- @test code[10 ] == Expr (:(= ), Core. SlotNumber (10 ), Expr (:call , GlobalRef (Base, :convert ), Core. SSAValue (field_type_ssa), Core. SlotNumber (10 )))
7469
- @test code[(slot_read_1 = 11 ;)] == Core. SlotNumber (10 )
7470
- @test code[(field_type2_ssa = 12 ;)] == Expr (:call , GlobalRef (Core, :fieldtype ), Core. SSAValue (apply_type_ssa), 2 )
7471
- @test code[18 ] == Expr (:(= ), Core. SlotNumber (9 ), Expr (:call , GlobalRef (Base, :convert ), Core. SSAValue (field_type2_ssa), Core. SlotNumber (9 )))
7472
- @test code[(slot_read_2 = 19 ;)] == Core. SlotNumber (9 )
7473
- @test code[(field_type4_ssa = 20 ;)] == Expr (:call , GlobalRef (Core, :fieldtype ), Core. SSAValue (apply_type_ssa), 4 )
7474
- @test code[26 ] == Expr (:(= ), Core. SlotNumber (8 ), Expr (:call , GlobalRef (Base, :convert ), Core. SSAValue (field_type4_ssa), Core. SlotNumber (8 )))
7475
- @test code[(slot_read_3 = 27 ;)] == Core. SlotNumber (8 )
7476
- @test code[(field_type5_ssa = 28 ;)] == Expr (:call , GlobalRef (Core, :fieldtype ), Core. SSAValue (apply_type_ssa), 5 )
7477
- @test code[34 ] == Expr (:(= ), Core. SlotNumber (7 ), Expr (:call , GlobalRef (Base, :convert ), Core. SSAValue (field_type5_ssa), Core. SlotNumber (7 )))
7478
- @test code[(slot_read_4 = 35 ;)] == Core. SlotNumber (7 )
7479
- @test code[(new_ssa = 36 ;)] == Expr (:new , Core. SSAValue (apply_type_ssa), Core. SSAValue (slot_read_1), Core. SSAValue (slot_read_2), Core. SlotNumber (4 ), Core. SSAValue (slot_read_3), Core. SSAValue (slot_read_4))
7480
- @test code[37 ] == Core. ReturnNode (Core. SSAValue (new_ssa))
7461
+ calls = Vector {Pair{SSAValue, Expr}} (undef, 0 )
7462
+ for i = 1 : length (code)
7463
+ expr = code[i]
7464
+ if Meta. isexpr (expr, :call ) || (Meta. isexpr (expr, :(= )) && Meta. isexpr (expr. args[2 ], :call ))
7465
+ push! (calls, SSAValue (i)=> expr)
7466
+ end
7467
+ end
7468
+
7469
+ function is_globalref (arg, gr)
7470
+ while isa (arg, SSAValue)
7471
+ arg = code[arg. id]
7472
+ end
7473
+ arg == gr
7474
+ end
7475
+
7476
+ # calls[1]
7477
+ @test all (is_globalref .(calls[1 ][2 ]. args[1 : 3 ], (GlobalRef (Core, :apply_type ), GlobalRef (@__MODULE__ , :FieldConvert ), GlobalRef (@__MODULE__ , :FieldTypeA ))))
7478
+
7479
+ # calls[2]
7480
+ @test all (is_globalref .(calls[2 ][2 ]. args[1 : 1 ], (GlobalRef (Core, :fieldtype ),)))
7481
+ @test all (calls[2 ][2 ]. args[2 : 3 ] .== (calls[1 ][1 ], 1 ))
7482
+
7483
+ # calls[3] - isa
7484
+
7485
+ # calls[4]
7486
+ let calle = calls[4 ][2 ]
7487
+ @test Meta. isexpr (calle, :(= ))
7488
+ call = calle. args[2 ]
7489
+ @test is_globalref (call. args[1 ], GlobalRef (Base, :convert ))
7490
+ @test call. args[2 ] == calls[2 ][1 ]
7491
+ end
7492
+
7493
+ # calls[5]
7494
+ @test all (is_globalref .(calls[5 ][2 ]. args[1 : 1 ], (GlobalRef (Core, :fieldtype ),)))
7495
+ @test all (calls[5 ][2 ]. args[2 : 3 ] .== (calls[1 ][1 ], 2 ))
7481
7496
end
7482
7497
7483
7498
# Issue #32820
@@ -8155,7 +8170,7 @@ end
8155
8170
@test Core. Compiler. is_foldable (Base. infer_effects (length, (Core. SimpleVector,)))
8156
8171
@test Core. Compiler. is_foldable (Base. infer_effects (getindex, (Core. SimpleVector,Int)))
8157
8172
8158
- # Test that a nothrow-globalref doesn't get outlined during lowering
8173
+ # Test that a the lowering of nothrow globalref
8159
8174
module WellKnownGlobal
8160
8175
global well_known = 1
8161
8176
end
@@ -8164,7 +8179,7 @@ macro insert_global()
8164
8179
end
8165
8180
check_globalref_lowering () = @insert_global
8166
8181
let src = code_lowered (check_globalref_lowering)[1 ]
8167
- @test length (src. code) == 2
8182
+ @test length (src. code) == 4
8168
8183
end
8169
8184
8170
8185
# Test correctness of widen_diagonal
0 commit comments