11// <rdar://problem/15358345> Check that we always use PIC relocations on all
22// platforms.
33
4- // RUN: %target-swift-frontend %s -module-name main -S -o - | %FileCheck -check-prefix=%target-cpu %s
4+ // RUN: %target-swift-frontend %s -module-name main -S -o - | %FileCheck -check-prefix=%target-cpu -check-prefix=%target-cpu-%target-sdk-name %s
55
66var global : Int = 0
77
@@ -20,12 +20,26 @@ public func use_global() -> Int {
2020// armv7-LABEL: {{_?}}$s4main10use_globalSiyF:
2121// Check for the runtime memory enforcement call. The global address may be
2222// materialized in a different register prior to that call.
23- // armv7: bl _swift_beginAccess
24- // armv7: movw [[R_ADR:r.*]], :lower16:(_$s4main6globalSivp-([[PIC_0:L.*]]+4))
25- // armv7: movt [[R_ADR]], :upper16:(_$s4main6globalSivp-([[PIC_0]]+4))
26- // armv7: [[PIC_0]]:{{$}}
27- // armv7: add [[R_ADR]], pc
28- // armv7: ldr [[R_ADR]], {{\[}}[[R_ADR]]{{\]}}
23+ // armv7: bl {{_?}}swift_beginAccess
24+ // armv7-iphoneos: movw [[R_ADR:r.*]], :lower16:(_$s4main6globalSivp-([[PIC_0:L.*]]+4))
25+ // armv7-iphoneos: movt [[R_ADR]], :upper16:(_$s4main6globalSivp-([[PIC_0]]+4))
26+ // armv7-iphoneos: [[PIC_0]]:{{$}}
27+ // armv7-iphoneos: ldr [[R_ADR]], {{\[}}[[R_ADR]]{{\]}}
28+
29+ // armv7-android: ldr [[R_ADR:r.*]], .LCPI[[PIC_0:[0-9]_[0-9]]]
30+ // armv7-android: .LPC[[PIC_0]]:{{$}}
31+ // armv7-android: add [[R_ADR]], pc
32+ // armv7-android: bl {{_?}}swift_endAccess
33+ // armv7-android: .LCPI[[PIC_0]]:{{$}}
34+ // armv7-android: .long ($s4main6globalSivp)-(.LPC[[PIC_0]]+8)
35+
36+ // armv7-linux: ldr [[R_ADR:r.*]], .LCPI[[PIC_0:[0-9]_[0-9]]]
37+ // armv7-linux: .LPC[[PIC_0]]:{{$}}
38+ // armv7-linux: add [[R_ADR]], pc
39+ // armv7-linux: bl {{_?}}swift_endAccess
40+ // armv7-linux: .LCPI[[PIC_0]]:{{$}}
41+ // armv7-linux: .long ($s4main6globalSivp)-(.LPC[[PIC_0]]+8)
42+
2943
3044// armv7s-LABEL: {{_?}}$s4main10use_globalSiyF:
3145// armv7s: bl _swift_beginAccess
@@ -53,13 +67,15 @@ public func use_global() -> Int {
5367// arm64: ldr x0, [sp]
5468
5569// aarch64-LABEL: $s4main10use_globalSiyF:
56- // aarch64: adrp [[REG1:x[0-9]+]], ($s4main6globalSivp@PAGE)
57- // aarch64: add [[REG1]], [[REG1]], :lo12:($s4main6globalSivp)
58- // aarch64: bl swift_beginAccess
59- // aarch64: ldr [[REG2:x[0-9]+]], {{\[}}[[REG1]]{{\]}}
60- // aarch64: str [[REG2]], [sp]
61- // aarch64: bl swift_endAccess
62- // aarch64: ldr x0, [sp]
70+ // aarch64: bl swift_beginAccess
71+ // aarch64-windows: adrp [[REG1:x[0-9]+]], ($s4main6globalSivp@PAGE)
72+ // aarch64-linux: adrp [[REG1:x[0-9]+]], ($s4main6globalSivp)
73+ // aarch64-android: adrp [[REG1:x[0-9]+]], ($s4main6globalSivp)
74+ // aarch64: add [[REG1]], [[REG1]], :lo12:($s4main6globalSivp)
75+ // aarch64: ldr [[REG2:x[0-9]+]], {{\[}}[[REG1]]{{\]}}
76+ // aarch64: str [[REG2]], [sp]
77+ // aarch64: bl swift_endAccess
78+ // aarch64: ldr x0, [sp]
6379
6480// powerpc64le-LABEL: {{_?}}$s4main10use_globalSiyF:
6581// powerpc64le: bl swift_beginAccess
0 commit comments