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

Unified 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: Update. Created 7 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« lib/Target/Mips/MipsMCInstLower.h ('K') | « lib/Target/Mips/MipsMCInstLower.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/MC/Mips/nacl-long-branch.ll
diff --git a/test/MC/Mips/nacl-long-branch.ll b/test/MC/Mips/nacl-long-branch.ll
new file mode 100644
index 0000000000000000000000000000000000000000..7293ef9203242d2cabd4d0ff5bcaa17773197496
--- /dev/null
+++ b/test/MC/Mips/nacl-long-branch.ll
@@ -0,0 +1,83 @@
+; RUN: llc -filetype=obj -sfi-load -sfi-store -sfi-stack -sfi-branch -sfi-data \
+; RUN: -force-mips-long-branch -O3 -mtriple mipsel-none-nacl %s -o - \
Mark Seaborn 2013/10/24 23:38:43 Can you indent these continuation lines for readab
petarj 2013/11/21 18:23:42 Done.
+; RUN: | llvm-objdump -triple mipsel -disassemble -no-show-raw-insn - \
+; RUN: | FileCheck %s
+
+
+declare void @f()
+
+define void @long_branch(i32 %arg) {
+entry:
+ %cmp = icmp eq i32 %arg, 0
+ br i1 %cmp, label %if.then, label %if.end
+if.then:
+ tail call void @f()
+ br label %if.end
+if.end:
+ ret void
+}
+
+; This file tests that MipsLongBranchPass works with sandboxing.
+; The nonsandboxed code of the previous function is:
+
+; long_branch:
+; 0: lui $2, 0
+; 4: addiu $2, $2, 0
+; 8: addiu $sp, $sp, -24
+; c: sw $ra, 20($sp)
+; 10: bne $4, $zero, 20
Mark Seaborn 2013/10/24 23:38:43 Might it be useful to add CHECKs for this case too
petarj 2013/11/21 18:23:42 Done.
+; 14: addu $gp, $2, $25
+; 18: lw $25, 0($gp)
+; 1c: jalr $25
+; 20: nop
+; 24: lw $ra, 20($sp)
+; 28: addiu $sp, $sp, 24
+; 2c: jr $ra
+; 30: nop
+
+; We pass -force-mips-long-branch option to llc to make sure that bne
+; instruction is expanded into long branch. We specifically test that
+; in the expanded sandboxed long branch sequence the offset that LUi/ADDiu
Mark Seaborn 2013/10/24 23:38:43 Can you add a comment explaining the arithmetic fo
petarj 2013/11/21 18:23:42 Done.
+; instructions create is the correct offset from the ADDiu instruction to the
+; branch target (which is lw $ra, 20($sp) in this case).
+
+; 0: lui $2, 0
+; 4: addiu $2, $2, 0
+; 8: addiu $sp, $sp, -24
+; c: and $sp, $sp, $15
+; 10: sw $ra, 20($sp)
+; 14: beq $4, $zero, 80
+; 18: addu $gp, $2, $25
+; 1c: nop
+; 20: addiu $sp, $sp, -8
+; 24: and $sp, $sp, $15
+; 28: sw $ra, 0($sp)
+; 2c: nop
+; 30: nop
+; 34: nop
+; CHECK: 38: bal 8
+; CHECK-NEXT: 3c: lui $1, 0
+; CHECK-NEXT: 40: addiu $1, $1, 64
+; 44: addu $1, $ra, $1
+; 48: lw $ra, 0($sp)
+; 4c: nop
+; 50: addiu $sp, $sp, 8
+; 54: and $sp, $sp, $15
+; 58: and $1, $1, $14
+; 5c: jr $1
Mark Seaborn 2013/10/24 23:38:43 The instructions from "bal 8" down to here are par
petarj 2013/11/21 18:23:42 Done.
+; 60: nop
+; 64: and $gp, $gp, $15
+; 68: lw $25, 0($gp)
+; 6c: nop
+; 70: nop
+; 74: and $25, $25, $14
+; 78: jalr $25
+; 7c: nop
+; CHECK: 80: lw $ra, 20($sp)
+; 84: addiu $sp, $sp, 24
+; 88: and $sp, $sp, $15
+; 8c: nop
+; 90: and $ra, $ra, $14
+; 94: jr $ra
+; 98: nop
+
« lib/Target/Mips/MipsMCInstLower.h ('K') | « lib/Target/Mips/MipsMCInstLower.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698