| 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 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 \ | 6 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -Om1 \ |
| 7 ; RUN: -allow-externally-defined-symbols | FileCheck %s | 7 ; RUN: -allow-externally-defined-symbols | FileCheck %s |
| 8 | 8 |
| 9 declare i32 @memcpy_helper2(i32 %buf, i32 %buf2, i32 %n) | 9 declare i32 @memcpy_helper2(i32 %buf, i32 %buf2, i32 %n) |
| 10 | 10 |
| 11 define internal i32 @memcpy_helper(i32 %buf, i32 %n) { | 11 define internal i32 @memcpy_helper(i32 %buf, i32 %n) { |
| 12 entry: | 12 entry: |
| 13 br label %eblock ; Disable alloca optimization | 13 br label %eblock ; Disable alloca optimization |
| 14 eblock: | 14 eblock: |
| 15 %buf2 = alloca i8, i32 128, align 4 | 15 %buf2 = alloca i8, i32 128, align 4 |
| 16 %n.arg_trunc = trunc i32 %n to i8 | 16 %n.arg_trunc = trunc i32 %n to i8 |
| 17 %arg.ext = zext i8 %n.arg_trunc to i32 | 17 %arg.ext = zext i8 %n.arg_trunc to i32 |
| 18 %buf2.asint = ptrtoint i8* %buf2 to i32 | 18 %buf2.asint = ptrtoint i8* %buf2 to i32 |
| 19 %call = call i32 @memcpy_helper2(i32 %buf, i32 %buf2.asint, i32 %arg.ext) | 19 %call = call i32 @memcpy_helper2(i32 %buf, i32 %buf2.asint, i32 %arg.ext) |
| 20 ret i32 %call | 20 ret i32 %call |
| 21 } | 21 } |
| 22 | 22 |
| 23 ; This check sequence is highly specific to the current Om1 lowering | 23 ; This check sequence is highly specific to the current Om1 lowering |
| 24 ; and stack slot assignment code, and may need to be relaxed if the | 24 ; and stack slot assignment code, and may need to be relaxed if the |
| 25 ; lowering code changes. | 25 ; lowering code changes. |
| 26 | 26 |
| 27 ; CHECK-LABEL: memcpy_helper | 27 ; CHECK-LABEL: memcpy_helper |
| 28 ; CHECK: push ebp | 28 ; CHECK: push ebp |
| 29 ; CHECK: mov ebp,esp | 29 ; CHECK: mov ebp,esp |
| 30 ; CHECK: sub esp,0x18 | 30 ; CHECK: sub esp,0x28 |
| 31 ; CHECK: sub esp,0x80 | 31 ; CHECK: sub esp,0x80 |
| 32 ; CHECK: mov DWORD PTR [ebp-0x4],esp | 32 ; CHECK: lea eax,[esp+0x10] |
| 33 ; CHECK: mov DWORD PTR [ebp-0x4],eax |
| 33 ; CHECK: mov eax,DWORD PTR [ebp+0xc] | 34 ; CHECK: mov eax,DWORD PTR [ebp+0xc] |
| 34 ; CHECK: mov BYTE PTR [ebp-0x8],al | 35 ; CHECK: mov BYTE PTR [ebp-0x8],al |
| 35 ; CHECK: movzx eax,BYTE PTR [ebp-0x8] | 36 ; CHECK: movzx eax,BYTE PTR [ebp-0x8] |
| 36 ; CHECK: mov DWORD PTR [ebp-0xc],eax | 37 ; CHECK: mov DWORD PTR [ebp-0xc],eax |
| 37 ; CHECK: sub esp,0x10 | |
| 38 ; CHECK: mov eax,DWORD PTR [ebp+0x8] | 38 ; CHECK: mov eax,DWORD PTR [ebp+0x8] |
| 39 ; CHECK: mov DWORD PTR [esp],eax | 39 ; CHECK: mov DWORD PTR [esp],eax |
| 40 ; CHECK: mov eax,DWORD PTR [ebp-0x4] | 40 ; CHECK: mov eax,DWORD PTR [ebp-0x4] |
| 41 ; CHECK: mov DWORD PTR [esp+0x4],eax | 41 ; CHECK: mov DWORD PTR [esp+0x4],eax |
| 42 ; CHECK: mov eax,DWORD PTR [ebp-0xc] | 42 ; CHECK: mov eax,DWORD PTR [ebp-0xc] |
| 43 ; CHECK: mov DWORD PTR [esp+0x8],eax | 43 ; CHECK: mov DWORD PTR [esp+0x8],eax |
| 44 ; CHECK: call {{.*}} R_{{.*}} memcpy_helper2 | 44 ; CHECK: call {{.*}} R_{{.*}} memcpy_helper2 |
| OLD | NEW |