Repository: apple/swift
File: test/IRGen/pic.swift (Swift)

Code before:
// armv7k:        add [[R_ADR]], pc
// armv7k:        ldr [[R_ADR]], {{\[}}[[R_ADR]]{{\]}}

// arm64-LABEL: {{_?}}$s4main10use_globalSiyF:
// arm64:        adrp [[REG3:x[0-9]+]], _$s4main6globalSivp@PAGE
// arm64:        str [[REG3]], [sp]
// arm64:        bl _swift_beginAccess
// arm64:        ldr [[REG4:x[0-9]+]], [sp]
// arm64:        ldr [[REG2:x[0-9]+]], {{\[}}[[REG4]], _$s4main6globalSivp@PAGEOFF
// arm64:        str [[REG2]], [sp, #16]
// arm64:        bl _swift_endAccess
// arm64:        ldr x0, [sp, #16]

// aarch64-LABEL: $s4main10use_globalSiyF:
// aarch64:         bl swift_beginAccess
// aarch64-linux:   adrp [[REG1:x[0-9]+]], ($s4main6globalSivp)
// aarch64-android: adrp [[REG1:x[0-9]+]], ($s4main6globalSivp)
// aarch64:         add [[REG1]], [[REG1]], :lo12:($s4main6globalSivp)
// aarch64:         ldr [[REG2:x[0-9]+]], {{\[}}[[REG1]]{{\]}}
// aarch64:         str [[REG2]], [sp]
// aarch64:         bl swift_endAccess
// aarch64:         ldr x0, [sp]

// aarch64-windows-LABEL: $s4main10use_globalSiyF:
// aarch64-windows:       adrp [[REG1:x[0-9]+]], $s4main6globalSivp
// aarch64-windows:       add  [[REG1]], [[REG1]], :lo12:$s4main6globalSivp
// aarch64-windows:       str  [[REG1]], [sp]
// aarch64-windows:       adrp [[REG2:x[0-9]+]], __imp_swift_beginAccess
// aarch64-windows:       ldr  [[REG2]], [[[REG2]], :lo12:__imp_swift_beginAccess]
// aarch64-windows:       blr  [[REG2]]
// aarch64-windows:       ldr  [[REG3:x[0-9]+]], [sp]
// aarch64-windows:       ldr  [[REG4:x[0-9]+]], [[[REG3]]]

// The following checks are temporarily disabled. See rdar://problem/42909618
// arm64e-LABEL: _$s4main10use_globalSiyF:
// arm64e:         bl _swift_beginAccess
// arm64e:          _$s4main6globalSivp@PAGEOFF
// arm64e:         bl _swift_endAccess

// arm64_32-LABEL: _$s4main10use_globalSiyF:
// arm64_32:         adrp [[REG1:x[0-9]+]], _$s4main6globalSivp@PAGE
// arm64_32:         add [[REG1]], [[REG1]], _$s4main6globalSivp@PAGEOFF
// arm64_32:         bl _swift_beginAccess
// arm64_32:         ldr {{w[0-9]+}}, {{\[}}[[REG1]]{{\]}}

// powerpc64le-LABEL: {{_?}}$s4main10use_globalSiyF:
// powerpc64le:        bl swift_beginAccess
// powerpc64le:       addi 3, 3, ($s4main6globalSivp)@toc@l

// s390x-LABEL: $s4main10use_globalSiyF:
// s390x:        lgrl    %[[REG1:r[0-9]+]], ($s4main6globalSivp)

Review comment (suggestion):
I don't remember off hand, but I think that there is a way to handle the difference better without the full replication.

Code after:
// arm64:        bl _swift_beginAccess
// arm64:        ldr [[REG4:x[0-9]+]], [sp]
// arm64:        ldr [[REG2:x[0-9]+]], {{\[}}[[REG4]], _$s4main6globalSivp@PAGEOFF
// arm64:        str [[REG2]], [sp, #16]
// arm64:        bl _swift_endAccess
// arm64:        ldr x0, [sp, #16]

// aarch64-LABEL: $s4main10use_globalSiyF:
// aarch64-SYSV:         bl swift_beginAccess
// aarch64-SYSV-linux:   adrp [[REG1:x[0-9]+]], ($s4main6globalSivp)
// aarch64-SYSV-android: adrp [[REG1:x[0-9]+]], ($s4main6globalSivp)
// aarch64-SYSV:         add [[REG1]], [[REG1]], :lo12:($s4main6globalSivp)
// aarch64-SYSV:         ldr [[REG2:x[0-9]+]], {{\[}}[[REG1]]{{\]}}
// aarch64-SYSV:         str [[REG2]], [sp]
// aarch64-SYSV:         bl swift_endAccess
// aarch64-SYSV:         ldr x0, [sp]

// aarch64-WIN:          adrp [[REG1:x[0-9]+]], $s4main6globalSivp
// aarch64-WIN:          add  [[REG1]], [[REG1]], :lo12:$s4main6globalSivp
// aarch64-WIN:          str  [[REG1]], [sp]
// aarch64-WIN:          adrp [[REG2:x[0-9]+]], __imp_swift_beginAccess
// aarch64-WIN:          ldr  [[REG2]], [[[REG2]], :lo12:__imp_swift_beginAccess]
// aarch64-WIN:          blr  [[REG2]]
// aarch64-WIN:          ldr  [[REG3:x[0-9]+]], [sp]
// aarch64-WIN:          ldr  [[REG4:x[0-9]+]], [[[REG3]]]

// The following checks are temporarily disabled. See rdar://problem/42909618
// arm64e-LABEL: _$s4main10use_globalSiyF:
// arm64e:         bl _swift_beginAccess
// arm64e:          _$s4main6globalSivp@PAGEOFF
// arm64e:         bl _swift_endAccess

// arm64_32-LABEL: _$s4main10use_globalSiyF:
// arm64_32:         adrp [[REG1:x[0-9]+]], _$s4main6globalSivp@PAGE
// arm64_32:         add [[REG1]], [[REG1]], _$s4main6globalSivp@PAGEOFF
// arm64_32:         bl _swift_beginAccess
// arm64_32:         ldr {{w[0-9]+}}, {{\[}}[[REG1]]{{\]}}

// powerpc64le-LABEL: {{_?}}$s4main10use_globalSiyF:
// powerpc64le:        bl swift_beginAccess
// powerpc64le:       addi 3, 3, ($s4main6globalSivp)@toc@l

// s390x-LABEL: $s4main10use_globalSiyF:
// s390x:        lgrl    %[[REG1:r[0-9]+]], ($s4main6globalSivp)