Skip to content

Commit daab6ad

Browse files
committed
[PowerPC][test] Improve .got2 and .toc tests
There is no .got2 test for powerpc32. There is no comdat variable test for powerpc{32,64}.
1 parent 496e0a9 commit daab6ad

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

llvm/test/CodeGen/PowerPC/mcm-1.ll

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
88
target triple = "powerpc64-unknown-linux-gnu"
99

10+
$fi = comdat any
11+
1012
@ei = external global i32
13+
@fi = global i32 0, align 4, comdat($fi)
14+
@gi = global i32 0, align 4, comdat($fi)
1115

1216
define signext i32 @test_external() nounwind {
1317
entry:
@@ -17,11 +21,25 @@ entry:
1721
ret i32 %0
1822
}
1923

24+
define i32 @load() {
25+
entry:
26+
%0 = load i32, i32* @gi, align 4
27+
%1 = load i32, i32* @fi, align 4
28+
%2 = add i32 %0, %1
29+
ret i32 %2
30+
}
31+
2032
; CHECK-LABEL: test_external:
2133
; CHECK: addis [[REG1:[0-9]+]], 2, .LC[[TOCNUM:[0-9]+]]@toc@ha
2234
; CHECK: ld [[REG2:[0-9]+]], .LC[[TOCNUM]]@toc@l([[REG1]])
2335
; CHECK: lwz {{[0-9]+}}, 0([[REG2]])
2436
; CHECK: stw {{[0-9]+}}, 0([[REG2]])
25-
; CHECK: .section .toc
26-
; CHECK: .LC[[TOCNUM]]:
27-
; CHECK: .tc {{[a-z0-9A-Z_.]+}}[TC],{{[a-z0-9A-Z_.]+}}
37+
38+
39+
; CHECK: .section .toc,"aw",@progbits
40+
; CHECK-NEXT: .LC0:
41+
; CHECK-NEXT: .tc ei[TC],ei
42+
; CHECK-NEXT: .LC1:
43+
; CHECK-NEXT: .tc fi[TC],fi
44+
; CHECK-NEXT: .LC2:
45+
; CHECK-NEXT: .tc gi[TC],gi

llvm/test/CodeGen/PowerPC/ppc32-pic-large.ll

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic | FileCheck -check-prefix=LARGE-BSS %s
2-
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
1+
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic | FileCheck --check-prefixes=LARGE,LARGE-BSS %s
2+
; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -mattr=+secure-plt -relocation-model=pic | FileCheck --check-prefixes=LARGE,LARGE-SECUREPLT %s
33
; RUN: llc < %s -mtriple=powerpc-unknown-netbsd -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
44
; RUN: llc < %s -mtriple=powerpc-unknown-netbsd -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
55
; RUN: llc < %s -mtriple=powerpc-unknown-openbsd -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
66
; RUN: llc < %s -mtriple=powerpc-unknown-openbsd -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
77
; RUN: llc < %s -mtriple=powerpc-linux-musl -mattr=+secure-plt -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
88
; RUN: llc < %s -mtriple=powerpc-linux-musl -relocation-model=pic | FileCheck -check-prefix=LARGE-SECUREPLT %s
9+
$bar1 = comdat any
10+
911
@bar = common global i32 0, align 4
12+
@bar1 = global i32 0, align 4, comdat($bar1)
13+
@bar2 = global i32 0, align 4, comdat($bar1)
1014

1115
declare i32 @call_foo(i32, ...)
1216

@@ -17,6 +21,14 @@ entry:
1721
ret i32 %0
1822
}
1923

24+
define i32 @load() {
25+
entry:
26+
%0 = load i32, i32* @bar1
27+
%1 = load i32, i32* @bar2
28+
%2 = add i32 %0, %1
29+
ret i32 %2
30+
}
31+
2032
!llvm.module.flags = !{!0}
2133
!0 = !{i32 1, !"PIC Level", i32 2}
2234
; LARGE-BSS: [[POFF:\.L[0-9]+\$poff]]:
@@ -33,10 +45,19 @@ entry:
3345
; LARGE-BSS-DAG: lwz {{[0-9]+}}, 0([[VREG]])
3446
; LARGE-BSS-DAG: stw {{[0-9]+}}, 8(1)
3547
; LARGE-BSS: lwz 30, 24(1)
36-
; LARGE-BSS: .section .got2,"aw",@progbits
37-
; LARGE-BSS-NEXT: .p2align 2
38-
; LARGE-BSS-NEXT: [[VREF]]:
39-
; LARGE-BSS-NEXT: .long bar
4048
; LARGE-SECUREPLT: addis 30, 30, .LTOC-.L0$pb@ha
4149
; LARGE-SECUREPLT: addi 30, 30, .LTOC-.L0$pb@l
4250
; LARGE-SECUREPLT: bl call_foo@PLT+32768
51+
52+
; LARGE: .section .bss.bar1,"aGw",@nobits,bar1,comdat
53+
; LARGE: bar1:
54+
; LARGE: .section .bss.bar2,"aGw",@nobits,bar1,comdat
55+
; LARGE: bar2:
56+
; LARGE: .section .got2,"aw",@progbits
57+
; LARGE-NEXT: .p2align 2
58+
; LARGE-NEXT: .LC0:
59+
; LARGE-NEXT: .long bar
60+
; LARGE-NEXT: .LC1:
61+
; LARGE-NEXT: .long bar1
62+
; LARGE-NEXT: .LC2:
63+
; LARGE-NEXT: .long bar2

0 commit comments

Comments
 (0)