| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | |
| ; Verify APX NF (no-flags) ADD/SUB used for the stack-pointer adjustment. | |
| ; | |
| ; NF is preferred only as a smaller replacement for LEA, i.e. only when EFLAGS | |
| ; must be preserved across the adjustment. The lea-sp tuning forces LEA for the | |
| ; SP, so it is the simplest way to exercise NF in both the prologue ({nf} subq) | |
| ; and the epilogue ({nf} addq). Without lea-sp the adjustment has dead EFLAGS | |
| ; and uses a plain (shorter) SUB/ADD instead. | |
| ; | |
| ; RUN: llc < %s -mtriple=x86_64-linux-gnu -mattr=+nf,+lea-sp | FileCheck %s --check-prefix=NF | |
| ; RUN: llc < %s -mtriple=x86_64-linux-gnu -mattr=+lea-sp | FileCheck %s --check-prefix=LEA | |
| ; RUN: llc < %s -mtriple=x86_64-linux-gnu -mattr=+nf | FileCheck %s --check-prefix=NONF | |
| ; | |
| ; The NF stack-adjust opcodes are 64-bit (SUB64ri32_NF/ADD64ri32_NF), so for the | |
| ; x32 ABI -- where the stack pointer is the 32-bit ESP -- NF must not be used; | |
| ; LEA on %esp is emitted instead. | |
| ; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+nf,+lea-sp -verify-machineinstrs | FileCheck %s --check-prefix=X32 | |
| declare void @callee(ptr) | |
| define void @f() { | |
| ; NF-LABEL: f: | |
| ; NF: # %bb.0: # %entry | |
| ; NF-NEXT: {nf} subq $72, %rsp | |
| ; NF-NEXT: .cfi_def_cfa_offset 80 | |
| ; NF-NEXT: movq %rsp, %rdi | |
| ; NF-NEXT: callq callee@PLT | |
| ; NF-NEXT: {nf} addq $72, %rsp | |
| ; NF-NEXT: .cfi_def_cfa_offset 8 | |
| ; NF-NEXT: retq | |
| ; | |
| ; LEA-LABEL: f: | |
| ; LEA: # %bb.0: # %entry | |
| ; LEA-NEXT: leaq -{{[0-9]+}}(%rsp), %rsp | |
| ; LEA-NEXT: .cfi_def_cfa_offset 80 | |
| ; LEA-NEXT: movq %rsp, %rdi | |
| ; LEA-NEXT: callq callee@PLT | |
| ; LEA-NEXT: leaq {{[0-9]+}}(%rsp), %rsp | |
| ; LEA-NEXT: .cfi_def_cfa_offset 8 | |
| ; LEA-NEXT: retq | |
| ; | |
| ; NONF-LABEL: f: | |
| ; NONF: # %bb.0: # %entry | |
| ; NONF-NEXT: subq $72, %rsp | |
| ; NONF-NEXT: .cfi_def_cfa_offset 80 | |
| ; NONF-NEXT: movq %rsp, %rdi | |
| ; NONF-NEXT: callq callee@PLT | |
| ; NONF-NEXT: addq $72, %rsp | |
| ; NONF-NEXT: .cfi_def_cfa_offset 8 | |
| ; NONF-NEXT: retq | |
| ; | |
| ; X32-LABEL: f: | |
| ; X32: # %bb.0: # %entry | |
| ; X32-NEXT: leal -{{[0-9]+}}(%esp), %esp | |
| ; X32-NEXT: .cfi_def_cfa_offset 80 | |
| ; X32-NEXT: movl %esp, %edi | |
| ; X32-NEXT: callq callee@PLT | |
| ; X32-NEXT: leal {{[0-9]+}}(%esp), %esp | |
| ; X32-NEXT: .cfi_def_cfa_offset 8 | |
| ; X32-NEXT: retq | |
| entry: | |
| %p = alloca [64 x i8], align 16 | |
| call void @callee(ptr %p) | |
| ret void | |
| } |