• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -filetype=asm -mtriple=mipsel-none-nacl -relocation-model=static \
2; RUN:     -O3 < %s | FileCheck %s
3
4
5; This test tests that NaCl functions are bundle-aligned.
6
7define void @test0() {
8  ret void
9
10; CHECK:          .align  4
11; CHECK-NOT:      .align
12; CHECK-LABEL:    test0:
13
14}
15
16
17; This test tests that blocks that are jumped to through jump table are
18; bundle-aligned.
19
20define i32 @test1(i32 %i) {
21entry:
22  switch i32 %i, label %default [
23    i32 0, label %bb1
24    i32 1, label %bb2
25    i32 2, label %bb3
26    i32 3, label %bb4
27  ]
28
29bb1:
30  ret i32 111
31bb2:
32  ret i32 222
33bb3:
34  ret i32 333
35bb4:
36  ret i32 444
37default:
38  ret i32 555
39
40
41; CHECK-LABEL:       test1:
42
43; CHECK:             .align  4
44; CHECK-NEXT:    ${{BB[0-9]+_[0-9]+}}:
45; CHECK-NEXT:        jr      $ra
46; CHECK-NEXT:        addiu   $2, $zero, 111
47; CHECK-NEXT:    ${{BB[0-9]+_[0-9]+}}:
48; CHECK-NEXT:        jr      $ra
49; CHECK-NEXT:        addiu   $2, $zero, 555
50; CHECK-NEXT:        .align  4
51; CHECK-NEXT:    ${{BB[0-9]+_[0-9]+}}:
52; CHECK-NEXT:        jr      $ra
53; CHECK-NEXT:        addiu   $2, $zero, 222
54; CHECK-NEXT:        .align  4
55; CHECK-NEXT:    ${{BB[0-9]+_[0-9]+}}:
56; CHECK-NEXT:        jr      $ra
57; CHECK-NEXT:        addiu   $2, $zero, 333
58
59}
60
61
62; This test tests that a block whose address is taken is bundle-aligned in NaCl.
63
64@bb_array = constant [2 x i8*] [i8* blockaddress(@test2, %bb1),
65                                i8* blockaddress(@test2, %bb2)], align 4
66
67define i32 @test2(i32 %i) {
68entry:
69  %elementptr = getelementptr inbounds [2 x i8*], [2 x i8*]* @bb_array, i32 0, i32 %i
70  %0 = load i8*, i8** %elementptr, align 4
71  indirectbr i8* %0, [label %bb1, label %bb2]
72
73bb1:
74  ret i32 111
75bb2:
76  ret i32 222
77
78
79; CHECK-LABEL:       test2:
80
81; Note that there are two consecutive labels - one temporary and one for
82; basic block.
83
84; CHECK:             .align  4
85; CHECK-NEXT:    ${{[a-zA-Z0-9]+}}:
86; CHECK-NEXT:    ${{BB[0-9]+_[0-9]+}}:
87; CHECK-NEXT:        jr      $ra
88; CHECK-NEXT:        addiu   $2, $zero, 111
89; CHECK-NEXT:        .align  4
90; CHECK-NEXT:    ${{[a-zA-Z0-9]+}}:
91; CHECK-NEXT:    ${{BB[0-9]+_[0-9]+}}:
92; CHECK-NEXT:        jr      $ra
93; CHECK-NEXT:        addiu   $2, $zero, 222
94
95}
96