Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: test/MC/Mips/nacl-long-branch.ll

Issue 27690005: [MIPS] Modify LongBranch expansion to work with sandboxing (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Changes per code review. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 ; RUN: llc -filetype=obj -sfi-load -sfi-store -sfi-stack -sfi-branch -sfi-data \
2 ; RUN: -force-mips-long-branch -O3 -mtriple mipsel-none-nacl %s -o - \
3 ; RUN: | llvm-objdump -triple mipsel -disassemble -no-show-raw-insn - \
4 ; RUN: | FileCheck %s
5
6 ; RUN: llc -filetype=obj -O3 -mtriple mipsel-none-nacl %s -o - \
7 ; RUN: | llvm-objdump -triple mipsel -disassemble -no-show-raw-insn - \
8 ; RUN: | FileCheck %s -check-prefix=CHECK-NOSFI
9
10
11 declare void @f()
12
13 define void @long_branch(i32 %arg) {
14 entry:
15 %cmp = icmp eq i32 %arg, 0
16 br i1 %cmp, label %if.then, label %if.end
17 if.then:
18 tail call void @f()
19 br label %if.end
20 if.end:
21 ret void
22 }
23
24 ; This file tests that MipsLongBranchPass works with sandboxing.
25 ; The nonsandboxed code of the previous function is:
26
27 ; long_branch:
28 ; CHECK-NOSFI: 0: lui $2, 0
29 ; CHECK-NOSFI: 4: addiu $2, $2, 0
30 ; CHECK-NOSFI: 8: addiu $sp, $sp, -24
31 ; CHECK-NOSFI: c: sw $ra, 20($sp)
32 ; CHECK-NOSFI: 10: bne $4, $zero, 20
33 ; CHECK-NOSFI: 14: addu $gp, $2, $25
34 ; CHECK-NOSFI: 18: lw $25, 0($gp)
35 ; CHECK-NOSFI: 1c: jalr $25
36 ; CHECK-NOSFI: 20: nop
37 ; CHECK-NOSFI: 24: lw $ra, 20($sp)
38 ; CHECK-NOSFI: 28: addiu $sp, $sp, 24
39 ; CHECK-NOSFI: 2c: jr $ra
40 ; CHECK-NOSFI: 30: nop
41
42 ; We pass -force-mips-long-branch option to llc to make sure that bne
43 ; instruction is expanded into long branch. We specifically test that
44 ; in the expanded sandboxed long branch sequence the offset that LUi/ADDiu
45 ; instructions create is the correct offset from the ADDiu instruction to the
46 ; branch target (which is lw $ra, 20($sp) in this case). More precisely:
47 ;
48 ; 0x80 - 0x40 = 64,
49 ; where 0x40 and 0x80 are addresses and 64 is in the "addiu" at 0x40.
50
51 ; 0: lui $2, 0
52 ; 4: addiu $2, $2, 0
53 ; 8: addiu $sp, $sp, -24
54 ; c: and $sp, $sp, $15
55 ; 10: sw $ra, 20($sp)
56 ; 14: beq $4, $zero, 80
57 ; 18: addu $gp, $2, $25
58 ; 1c: nop
59 ; 20: addiu $sp, $sp, -8
60 ; 24: and $sp, $sp, $15
61 ; 28: sw $ra, 0($sp)
62 ; 2c: nop
63 ; 30: nop
64 ; 34: nop
65 ; CHECK: 38: bal 8
66 ; CHECK-NEXT: 3c: lui $1, 0
67 ; CHECK-NEXT: 40: addiu $1, $1, 64
68 ; CHECK: addu $1, $ra, $1
69 ; CHECK: lw $ra, 0($sp)
70 ; CHECK: nop
71 ; CHECK: addiu $sp, $sp, 8
72 ; CHECK: and $sp, $sp, $15
73 ; CHECK: and $1, $1, $14
74 ; CHECK: jr $1
75 ; CHECK: nop
76 ; 64: and $gp, $gp, $15
77 ; 68: lw $25, 0($gp)
78 ; 6c: nop
79 ; 70: nop
80 ; 74: and $25, $25, $14
81 ; 78: jalr $25
82 ; 7c: nop
83 ; CHECK: 80: lw $ra, 20($sp)
84 ; 84: addiu $sp, $sp, 24
85 ; 88: and $sp, $sp, $15
86 ; 8c: nop
87 ; 90: and $ra, $ra, $14
88 ; 94: jr $ra
89 ; 98: nop
OLDNEW
« lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp ('K') | « lib/Target/Mips/MipsMCInstLower.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698