diff options
author | Logan Chien <tzuhsiang.chien@gmail.com> | 2013-06-09 12:22:30 +0000 |
---|---|---|
committer | Logan Chien <tzuhsiang.chien@gmail.com> | 2013-06-09 12:22:30 +0000 |
commit | 18cba562c8016f8095643b5dd8c4b34b294b62dd (patch) | |
tree | 5aad10d696d68909871a4743f444591b07007324 /test | |
parent | 40e071c1eb3a6a57579f80b910ff7323048bbc09 (diff) | |
download | external_llvm-18cba562c8016f8095643b5dd8c4b34b294b62dd.zip external_llvm-18cba562c8016f8095643b5dd8c4b34b294b62dd.tar.gz external_llvm-18cba562c8016f8095643b5dd8c4b34b294b62dd.tar.bz2 |
Fix ARM unwind opcode assembler in several cases.
Changes to ARM unwind opcode assembler:
* Fix multiple .save or .vsave directives. Besides, the
order is preserved now.
* For the directives which will generate multiple opcodes,
such as ".save {r0-r11}", the order of the unwind opcode
is fixed now, i.e. the registers with less encoding value
are popped first.
* Fix the $sp offset calculation. Now, we can use the
.setfp, .pad, .save, and .vsave directives at any order.
Changes to test cases:
* Add test cases to check the order of multiple opcodes
for the .save directive.
* Fix the incorrect $sp offset in the test case. The
stack pointer offset specified in the test case was
incorrect. (Changed test cases: ehabi-mc-section.ll and
ehabi-mc.ll)
* The opcode to restore $sp are slightly reordered. The
behavior are not changed, and the new output is same
as the output of GNU as. (Changed test cases:
eh-directive-pad.s and eh-directive-setfp.s)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183627 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/ARM/ehabi-mc-section.ll | 2 | ||||
-rw-r--r-- | test/CodeGen/ARM/ehabi-mc.ll | 2 | ||||
-rw-r--r-- | test/MC/ARM/eh-directive-integrated-test.s | 93 | ||||
-rw-r--r-- | test/MC/ARM/eh-directive-multiple-offsets.s | 168 | ||||
-rw-r--r-- | test/MC/ARM/eh-directive-pad.s | 6 | ||||
-rw-r--r-- | test/MC/ARM/eh-directive-save.s | 45 | ||||
-rw-r--r-- | test/MC/ARM/eh-directive-setfp.s | 6 |
7 files changed, 314 insertions, 8 deletions
diff --git a/test/CodeGen/ARM/ehabi-mc-section.ll b/test/CodeGen/ARM/ehabi-mc-section.ll index 4e6e468..51ae25a 100644 --- a/test/CodeGen/ARM/ehabi-mc-section.ll +++ b/test/CodeGen/ARM/ehabi-mc-section.ll @@ -60,7 +60,7 @@ declare void @_ZSt9terminatev() ; CHECK: section .test_section ; CHECK: section .ARM.extab.test_section -; CHECK-NEXT: 0000 00000000 c9409b01 b0818484 +; CHECK-NEXT: 0000 00000000 c94a9b01 b0818484 ; CHECK: section .ARM.exidx.test_section ; CHECK-NEXT: 0000 00000000 00000000 diff --git a/test/CodeGen/ARM/ehabi-mc.ll b/test/CodeGen/ARM/ehabi-mc.ll index 83b8425..b0fc81e 100644 --- a/test/CodeGen/ARM/ehabi-mc.ll +++ b/test/CodeGen/ARM/ehabi-mc.ll @@ -60,7 +60,7 @@ declare void @_ZSt9terminatev() ; CHECK: section .text ; CHECK: section .ARM.extab -; CHECK-NEXT: 0000 00000000 c9409b01 b0818484 +; CHECK-NEXT: 0000 00000000 c94a9b01 b0818484 ; CHECK: section .ARM.exidx ; CHECK-NEXT: 0000 00000000 00000000 diff --git a/test/MC/ARM/eh-directive-integrated-test.s b/test/MC/ARM/eh-directive-integrated-test.s new file mode 100644 index 0000000..df2b290 --- /dev/null +++ b/test/MC/ARM/eh-directive-integrated-test.s @@ -0,0 +1,93 @@ +@ Integrated test for ARM unwind directive parser and assembler. + +@ This is a simplified real world test case generated from this C++ code +@ (with and without -fomit-frame-pointer) +@ +@ extern void print(int, int, int, int, int); +@ extern void print(double, double, double, double, double); +@ +@ void test(int a, int b, int c, int d, int e, +@ double m, double n, double p, double q, double r) { +@ try { +@ print(a, b, c, d, e); +@ } catch (...) { +@ print(m, n, p, q, r); +@ } +@ } +@ +@ This test case should check the unwind opcode to adjust the opcode and +@ restore the general-purpose and VFP registers. + + +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd | FileCheck %s + + +@------------------------------------------------------------------------------- +@ Assembly without frame pointer elimination +@------------------------------------------------------------------------------- + .syntax unified + .section .TEST1 + .globl func1 + .align 2 + .type func1,%function +func1: + .fnstart + .save {r4, r11, lr} + push {r4, r11, lr} + .setfp r11, sp, #4 + add r11, sp, #4 + .vsave {d8, d9, d10, d11, d12} + vpush {d8, d9, d10, d11, d12} + .pad #28 + sub sp, sp, #28 + sub sp, r11, #44 + vpop {d8, d9, d10, d11, d12} + pop {r4, r11, pc} +.Ltmp1: + .size func1, .Ltmp1-func1 + .globl __gxx_personality_v0 + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 C94A9B01 B0818484 |.....J......| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ Assembly with frame pointer elimination +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2 + .align 2 + .type func2,%function +func2: + .fnstart + .save {r4, lr} + push {r4, lr} + .vsave {d8, d9, d10, d11, d12} + vpush {d8, d9, d10, d11, d12} + .pad #24 + sub sp, sp, #24 + add sp, sp, #24 + vpop {d8, d9, d10, d11, d12} + pop {r4, pc} +.Ltmp2: + .size func2, .Ltmp2-func2 + .globl __gxx_personality_v0 + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 84C90501 B0B0B0A8 |............| +@ CHECK: ) +@ CHECK: } diff --git a/test/MC/ARM/eh-directive-multiple-offsets.s b/test/MC/ARM/eh-directive-multiple-offsets.s new file mode 100644 index 0000000..6e81f41 --- /dev/null +++ b/test/MC/ARM/eh-directive-multiple-offsets.s @@ -0,0 +1,168 @@ +@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ +@ RUN: | llvm-readobj -s -sd | FileCheck %s + +@ Check for different combination of .setfp, .pad, .save and .vsave. + + .syntax unified + +@------------------------------------------------------------------------------- +@ TEST1: Check .pad before .setfp directive. +@------------------------------------------------------------------------------- + .section .TEST1 + .globl func1 + .type func1,%function + .align 2 + .fnstart +func1: + .pad #12 + sub sp, sp, #12 + .setfp fp, sp, #8 + add fp, sp, #8 + sub sp, fp, #8 + add sp, sp, #12 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST1 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0009B00 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST2: Check .pad after .setfp directive. +@------------------------------------------------------------------------------- + .section .TEST2 + .globl func2 + .type func2,%function + .align 2 + .fnstart +func2: + .setfp fp, sp, #8 + add fp, sp, #8 + .pad #12 + sub sp, sp, #12 + add sp, sp, #12 + sub sp, fp, #8 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST2 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0419B00 |.....A..| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST3: Check .setfp, .pad, .setfp directive. +@------------------------------------------------------------------------------- + .section .TEST3 + .globl func3 + .type func3,%function + .align 2 + .fnstart +func3: + @ prologue: + .setfp fp, sp, #4 + add fp, sp, #4 + .pad #8 + sub sp, sp, #8 + .setfp fp, sp, #4 + add fp, sp, #4 + + @ epilogue: + add sp, fp, #4 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST3 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0009B00 |........| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST4: Check ".setfp fp, sp" and ".setfp fp, fp" directive. +@------------------------------------------------------------------------------- + .section .TEST4 + .globl func4 + .type func4,%function + .align 2 + .fnstart +func4: + @ prologue: + .setfp fp, sp, #8 + add fp, sp, #8 + .setfp fp, fp, #8 + add fp, fp, #8 + + @ epilogue: + sub sp, fp, #16 + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST4 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 B0439B00 |.....C..| +@ CHECK: ) +@ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST5: Check .setfp, .save, .setfp directive. +@------------------------------------------------------------------------------- + .section .TEST5 + .globl func5 + .type func5,%function + .align 2 + .fnstart +func5: + @ prologue: + .setfp fp, sp, #16 + add fp, sp, #16 + .save {r4, r5, r6, r7, r8} + push {r4, r5, r6, r7, r8} + .pad #8 + add sp, sp, #8 + .pad #8 + sub sp, sp, #8 + .save {r9, r10} + push {r9, r10} + .setfp fp, sp, #24 + add fp, sp, #24 + + @ epilogue: + sub sp, fp, #24 + pop {r9, r10} + add sp, sp, #16 + pop {r4, r5, r6, r7, r8} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST5 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 80459B01 B0A40360 |.....E.....`| +@ CHECK: ) +@ CHECK: } diff --git a/test/MC/ARM/eh-directive-pad.s b/test/MC/ARM/eh-directive-pad.s index ba850ff..f8263e6 100644 --- a/test/MC/ARM/eh-directive-pad.s +++ b/test/MC/ARM/eh-directive-pad.s @@ -121,7 +121,7 @@ func3b: @ CHECK: Section { @ CHECK: Name: .ARM.extab.TEST3 @ CHECK: SectionData ( -@ CHECK: 0000: 00000000 B0003F00 00000000 B03F3F00 |......?......??.| +@ CHECK: 0000: 00000000 B03F0000 00000000 B03F3F00 |.....?.......??.| @ CHECK: ) @ CHECK: } @@ -220,7 +220,7 @@ func5c: @ CHECK: Section { @ CHECK: Name: .ARM.extab.TEST5 @ CHECK: SectionData ( -@ CHECK: 0000: 00000000 B0B04000 00000000 B0407F00 |......@......@..| -@ CHECK: 0010: 00000000 407F7F00 |....@...| +@ CHECK: 0000: 00000000 B0B04000 00000000 B07F4000 |......@.......@.| +@ CHECK: 0010: 00000000 7F7F4000 |......@.| @ CHECK: ) @ CHECK: } diff --git a/test/MC/ARM/eh-directive-save.s b/test/MC/ARM/eh-directive-save.s index f9c8c5f..652a7bb 100644 --- a/test/MC/ARM/eh-directive-save.s +++ b/test/MC/ARM/eh-directive-save.s @@ -296,3 +296,48 @@ func4e: @ CHECK: 0020: 00000000 B00E8400 |........| @ CHECK: ) @ CHECK: } + + + +@------------------------------------------------------------------------------- +@ TEST5 +@------------------------------------------------------------------------------- + .section .TEST5 + .globl func5a + .align 2 + .type func5a,%function + .fnstart +func5a: + .save {r0, r1, r2, r3, r4, r5, r6} + push {r0, r1, r2, r3, r4, r5, r6} + pop {r0, r1, r2, r3, r4, r5, r6} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + + .globl func5b + .align 2 + .type func5b,%function + .fnstart +func5b: + .save {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r14} + push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r14} + pop {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r14} + bx lr + .personality __gxx_personality_v0 + .handlerdata + .fnend + +@------------------------------------------------------------------------------- +@ Check the order of unwind opcode to pop registers. +@ 0xB10F "pop {r0-r3}" should be emitted before 0xA2 "pop {r4-r6}". +@ 0xB10F "pop {r0-r3}" should be emitted before 0x85FF "pop {r4-r12, r14}". +@------------------------------------------------------------------------------- +@ CHECK: Section { +@ CHECK: Name: .ARM.extab.TEST5 +@ CHECK: SectionData ( +@ CHECK: 0000: 00000000 A20FB100 00000000 850FB101 |................| +@ CHECK: 0010: B0B0B0FF |....| +@ CHECK: ) +@ CHECK: } diff --git a/test/MC/ARM/eh-directive-setfp.s b/test/MC/ARM/eh-directive-setfp.s index 3fbab5a..dfa79e6 100644 --- a/test/MC/ARM/eh-directive-setfp.s +++ b/test/MC/ARM/eh-directive-setfp.s @@ -131,7 +131,7 @@ func3b: @ CHECK: Section { @ CHECK: Name: .ARM.extab.TEST3 @ CHECK: SectionData ( -@ CHECK: 0000: 00000000 003F9B00 00000000 3F3F9B00 |.....?......??..| +@ CHECK: 0000: 00000000 3F009B00 00000000 3F3F9B00 |....?.......??..| @ CHECK: ) @ CHECK: } @@ -233,7 +233,7 @@ func5c: @ CHECK: Section { @ CHECK: Name: .ARM.extab.TEST5 @ CHECK: SectionData ( -@ CHECK: 0000: 00000000 B0409B00 00000000 407F9B00 |.....@......@...| -@ CHECK: 0010: 00000000 7F7F9B01 B0B0B040 |...........@| +@ CHECK: 0000: 00000000 B0409B00 00000000 7F409B00 |.....@.......@..| +@ CHECK: 0010: 00000000 7F409B01 B0B0B07F |.....@......| @ CHECK: ) @ CHECK: } |