OLD | NEW |
1 ; This test originally exhibited a bug in ebp-based stack slots. The | 1 ; This test originally exhibited a bug in ebp-based stack slots. The |
2 ; problem was that during a function call push sequence, the esp | 2 ; problem was that during a function call push sequence, the esp |
3 ; adjustment was incorrectly added to the stack/frame offset for | 3 ; adjustment was incorrectly added to the stack/frame offset for |
4 ; ebp-based frames. | 4 ; ebp-based frames. |
5 | 5 |
6 ; TODO(kschimpf) Find out why lc2i is needed. | 6 ; RUN: %p2i -i %s --args -Om1 --target=x8632 --verbose none \ |
7 ; REQUIRES: allow_llvm_ir_as_input | |
8 ; RUN: %lc2i -i %s --args -Om1 --target=x8632 --verbose none \ | |
9 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ | 7 ; RUN: | llvm-mc -triple=i686-none-nacl -filetype=obj \ |
10 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s | 8 ; RUN: | llvm-objdump -d --symbolize -x86-asm-syntax=intel - | FileCheck %s |
11 | 9 |
12 declare i32 @memcpy_helper2(i32 %buf, i32 %buf2, i32 %n) | 10 declare i32 @memcpy_helper2(i32 %buf, i32 %buf2, i32 %n) |
13 | 11 |
14 define i32 @memcpy_helper(i32 %buf, i32 %n) { | 12 define i32 @memcpy_helper(i32 %buf, i32 %n) { |
15 entry: | 13 entry: |
| 14 %buf2 = alloca i8, i32 128, align 4 |
16 %n.arg_trunc = trunc i32 %n to i8 | 15 %n.arg_trunc = trunc i32 %n to i8 |
17 %buf2 = alloca i8, i32 128, align 4 | 16 %arg_ext = zext i8 %n.arg_trunc to i32 |
18 %buf2.asint = ptrtoint i8* %buf2 to i32 | 17 %buf2.asint = ptrtoint i8* %buf2 to i32 |
19 %arg_ext = zext i8 %n.arg_trunc to i32 | |
20 %call = call i32 @memcpy_helper2(i32 %buf, i32 %buf2.asint, i32 %arg_ext) | 18 %call = call i32 @memcpy_helper2(i32 %buf, i32 %buf2.asint, i32 %arg_ext) |
21 ret i32 %call | 19 ret i32 %call |
22 } | 20 } |
23 | 21 |
24 ; This check sequence is highly specific to the current Om1 lowering | 22 ; This check sequence is highly specific to the current Om1 lowering |
25 ; and stack slot assignment code, and may need to be relaxed if the | 23 ; and stack slot assignment code, and may need to be relaxed if the |
26 ; lowering code changes. | 24 ; lowering code changes. |
27 | 25 |
28 ; CHECK-LABEL: memcpy_helper: | 26 ; CHECK-LABEL: memcpy_helper: |
29 ; CHECK: push ebp | 27 ; CHECK: push ebp |
30 ; CHECK: mov ebp, esp | 28 ; CHECK: mov ebp, esp |
31 ; CHECK: sub esp, 24 | 29 ; CHECK: sub esp, 24 |
| 30 ; CHECK: sub esp, 128 |
| 31 ; CHECK: mov dword ptr [ebp - 4], esp |
32 ; CHECK: mov eax, dword ptr [ebp + 12] | 32 ; CHECK: mov eax, dword ptr [ebp + 12] |
33 ; CHECK: mov dword ptr [ebp - 4], eax | 33 ; CHECK: mov dword ptr [ebp - 8], eax |
34 ; CHECK: sub esp, 128 | 34 ; CHECK: movzx eax, byte ptr [ebp - 8] |
35 ; CHECK: mov dword ptr [ebp - 8], esp | |
36 ; CHECK: mov eax, dword ptr [ebp - 8] | |
37 ; CHECK: mov dword ptr [ebp - 12], eax | 35 ; CHECK: mov dword ptr [ebp - 12], eax |
38 ; CHECK: movzx eax, byte ptr [ebp - 4] | |
39 ; CHECK: mov dword ptr [ebp - 16], eax | |
40 ; CHECK: sub esp, 16 | 36 ; CHECK: sub esp, 16 |
41 ; CHECK: mov eax, dword ptr [ebp + 8] | 37 ; CHECK: mov eax, dword ptr [ebp + 8] |
42 ; CHECK: mov dword ptr [esp], eax | 38 ; CHECK: mov dword ptr [esp], eax |
| 39 ; CHECK: mov eax, dword ptr [ebp - 4] |
| 40 ; CHECK: mov dword ptr [esp + 4], eax |
43 ; CHECK: mov eax, dword ptr [ebp - 12] | 41 ; CHECK: mov eax, dword ptr [ebp - 12] |
44 ; CHECK: mov dword ptr [esp + 4], eax | |
45 ; CHECK: mov eax, dword ptr [ebp - 16] | |
46 ; CHECK: mov dword ptr [esp + 8], eax | 42 ; CHECK: mov dword ptr [esp + 8], eax |
47 ; CHECK: call memcpy_helper2 | 43 ; CHECK: call memcpy_helper2 |
OLD | NEW |