@@ -370,6 +370,85 @@ bb0:
370370
371371sil_global @global1 : $Int64
372372sil_global @global2 : $Int64
373+ sil_global @somePointer : $Builtin.RawPointer
374+
375+ sil [global_init] [ossa] @addressor_of_global1 : $@convention(thin) () -> Builtin.RawPointer {
376+ bb0:
377+ %0 = global_addr @global1 : $*Int64
378+ %1 = address_to_pointer %0 : $*Int64 to $Builtin.RawPointer
379+ return %1 : $Builtin.RawPointer
380+ }
381+
382+ sil [global_init] [ossa] @external_addressor_of_global1 : $@convention(thin) () -> Builtin.RawPointer
383+
384+ sil [global_init] [ossa] @wrong_addressor_of_global1 : $@convention(thin) () -> Builtin.RawPointer {
385+ bb0:
386+ %0 = global_addr @somePointer : $*Builtin.RawPointer
387+ %1 = load [trivial] %0 : $*Builtin.RawPointer
388+ return %1 : $Builtin.RawPointer
389+ }
390+
391+ // CHECK-LABEL: Accesses for testSimpleGlobal
392+ // CHECK-NEXT: Value: %0 = global_addr @global1 : $*Int64
393+ // CHECK-NEXT: Scope: base
394+ // CHECK-NEXT: Base: global - @global1
395+ // CHECK-NEXT: Path: ""
396+ // CHECK-NEXT: no Storage paths
397+ // CHECK-NEXT: End accesses for testSimpleGlobal
398+ sil [ossa] @testSimpleGlobal : $@convention(thin) () -> Int64 {
399+ bb0:
400+ %0 = global_addr @global1 : $*Int64
401+ %1 = load [trivial] %0 : $*Int64
402+ return %1 : $Int64
403+ }
404+
405+ // CHECK-LABEL: Accesses for testGlobalViaAddressor
406+ // CHECK-NEXT: Value: %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
407+ // CHECK-NEXT: Scope: base
408+ // CHECK-NEXT: Base: global - @global1
409+ // CHECK-NEXT: Path: ""
410+ // CHECK-NEXT: no Storage paths
411+ // CHECK-NEXT: End accesses for testGlobalViaAddressor
412+ sil [ossa] @testGlobalViaAddressor : $@convention(thin) () -> Int64 {
413+ bb0:
414+ %0 = function_ref @addressor_of_global1 : $@convention(thin) () -> Builtin.RawPointer
415+ %1 = apply %0() : $@convention(thin) () -> Builtin.RawPointer
416+ %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
417+ %3 = load [trivial] %2 : $*Int64
418+ return %3 : $Int64
419+ }
420+
421+ // CHECK-LABEL: Accesses for testGlobalViaUnknwonAddressor
422+ // CHECK-NEXT: Value: %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
423+ // CHECK-NEXT: Scope: base
424+ // CHECK-NEXT: Base: pointer - %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
425+ // CHECK-NEXT: Path: ""
426+ // CHECK-NEXT: no Storage paths
427+ // CHECK-NEXT: End accesses for testGlobalViaUnknwonAddressor
428+ sil [ossa] @testGlobalViaUnknwonAddressor : $@convention(thin) () -> Int64 {
429+ bb0:
430+ %0 = function_ref @external_addressor_of_global1 : $@convention(thin) () -> Builtin.RawPointer
431+ %1 = apply %0() : $@convention(thin) () -> Builtin.RawPointer
432+ %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
433+ %3 = load [trivial] %2 : $*Int64
434+ return %3 : $Int64
435+ }
436+
437+ // CHECK-LABEL: Accesses for testGlobalViaWrongAddressor
438+ // CHECK-NEXT: Value: %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
439+ // CHECK-NEXT: Scope: base
440+ // CHECK-NEXT: Base: pointer - %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
441+ // CHECK-NEXT: Path: ""
442+ // CHECK-NEXT: no Storage paths
443+ // CHECK-NEXT: End accesses for testGlobalViaWrongAddressor
444+ sil [ossa] @testGlobalViaWrongAddressor : $@convention(thin) () -> Int64 {
445+ bb0:
446+ %0 = function_ref @wrong_addressor_of_global1 : $@convention(thin) () -> Builtin.RawPointer
447+ %1 = apply %0() : $@convention(thin) () -> Builtin.RawPointer
448+ %2 = pointer_to_address %1 : $Builtin.RawPointer to [strict] $*Int64
449+ %3 = load [trivial] %2 : $*Int64
450+ return %3 : $Int64
451+ }
373452
374453sil @coro : $@yield_once @convention(thin) () -> @yields @inout Int64
375454
0 commit comments