mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
9686e666ef
This patch aims to provide correct dwarf unwind information in function epilogue for X86. It consists of two parts. The first part inserts CFI instructions that set appropriate cfa offset and cfa register in emitEpilogue() in X86FrameLowering. This part is X86 specific. The second part is platform independent and ensures that: * CFI instructions do not affect code generation (they are not counted as instructions when tail duplicating or tail merging) * Unwind information remains correct when a function is modified by different passes. This is done in a late pass by analyzing information about cfa offset and cfa register in BBs and inserting additional CFI directives where necessary. Added CFIInstrInserter pass: * analyzes each basic block to determine cfa offset and register are valid at its entry and exit * verifies that outgoing cfa offset and register of predecessor blocks match incoming values of their successors * inserts additional CFI directives at basic block beginning to correct the rule for calculating CFA Having CFI instructions in function epilogue can cause incorrect CFA calculation rule for some basic blocks. This can happen if, due to basic block reordering, or the existence of multiple epilogue blocks, some of the blocks have wrong cfa offset and register values set by the epilogue block above them. CFIInstrInserter is currently run only on X86, but can be used by any target that implements support for adding CFI instructions in epilogue. Patch by Violeta Vukobrat. Differential Revision: https://reviews.llvm.org/D42848 llvm-svn: 330706
102 lines
3.3 KiB
LLVM
102 lines
3.3 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64
|
|
; RUN: llc < %s -mtriple=i386-unknown | FileCheck %s --check-prefix=X86
|
|
|
|
define i128 @foo(i128 %t, i128 %u) {
|
|
; X64-LABEL: foo:
|
|
; X64: # %bb.0:
|
|
; X64-NEXT: movq %rdx, %r8
|
|
; X64-NEXT: imulq %rdi, %rcx
|
|
; X64-NEXT: movq %rdi, %rax
|
|
; X64-NEXT: mulq %rdx
|
|
; X64-NEXT: addq %rcx, %rdx
|
|
; X64-NEXT: imulq %r8, %rsi
|
|
; X64-NEXT: addq %rsi, %rdx
|
|
; X64-NEXT: retq
|
|
;
|
|
; X86-LABEL: foo:
|
|
; X86: # %bb.0:
|
|
; X86-NEXT: pushl %ebp
|
|
; X86-NEXT: .cfi_def_cfa_offset 8
|
|
; X86-NEXT: pushl %ebx
|
|
; X86-NEXT: .cfi_def_cfa_offset 12
|
|
; X86-NEXT: pushl %edi
|
|
; X86-NEXT: .cfi_def_cfa_offset 16
|
|
; X86-NEXT: pushl %esi
|
|
; X86-NEXT: .cfi_def_cfa_offset 20
|
|
; X86-NEXT: subl $8, %esp
|
|
; X86-NEXT: .cfi_def_cfa_offset 28
|
|
; X86-NEXT: .cfi_offset %esi, -20
|
|
; X86-NEXT: .cfi_offset %edi, -16
|
|
; X86-NEXT: .cfi_offset %ebx, -12
|
|
; X86-NEXT: .cfi_offset %ebp, -8
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
|
|
; X86-NEXT: imull %edx, %esi
|
|
; X86-NEXT: movl %edi, %eax
|
|
; X86-NEXT: mull %edx
|
|
; X86-NEXT: movl %eax, %ebx
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
; X86-NEXT: imull %edi, %ecx
|
|
; X86-NEXT: addl %edx, %ecx
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-NEXT: addl %esi, %ecx
|
|
; X86-NEXT: movl %eax, %esi
|
|
; X86-NEXT: imull {{[0-9]+}}(%esp), %esi
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %ebp
|
|
; X86-NEXT: mull %ebp
|
|
; X86-NEXT: addl %esi, %edx
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %edi
|
|
; X86-NEXT: imull %ebp, %edi
|
|
; X86-NEXT: addl %edx, %edi
|
|
; X86-NEXT: addl %ebx, %eax
|
|
; X86-NEXT: movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
|
|
; X86-NEXT: adcl %ecx, %edi
|
|
; X86-NEXT: movl %ebp, %eax
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
; X86-NEXT: mull %ecx
|
|
; X86-NEXT: movl %edx, %ebx
|
|
; X86-NEXT: movl %eax, (%esp) # 4-byte Spill
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-NEXT: mull %ecx
|
|
; X86-NEXT: movl %edx, %esi
|
|
; X86-NEXT: movl %eax, %ecx
|
|
; X86-NEXT: addl %ebx, %ecx
|
|
; X86-NEXT: adcl $0, %esi
|
|
; X86-NEXT: movl %ebp, %eax
|
|
; X86-NEXT: mull {{[0-9]+}}(%esp)
|
|
; X86-NEXT: movl %edx, %ebx
|
|
; X86-NEXT: movl %eax, %ebp
|
|
; X86-NEXT: addl %ecx, %ebp
|
|
; X86-NEXT: adcl %esi, %ebx
|
|
; X86-NEXT: setb %cl
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
; X86-NEXT: mull {{[0-9]+}}(%esp)
|
|
; X86-NEXT: addl %ebx, %eax
|
|
; X86-NEXT: movzbl %cl, %ecx
|
|
; X86-NEXT: adcl %ecx, %edx
|
|
; X86-NEXT: addl {{[0-9]+}}(%esp), %eax # 4-byte Folded Reload
|
|
; X86-NEXT: adcl %edi, %edx
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
|
; X86-NEXT: movl (%esp), %esi # 4-byte Reload
|
|
; X86-NEXT: movl %esi, (%ecx)
|
|
; X86-NEXT: movl %ebp, 4(%ecx)
|
|
; X86-NEXT: movl %eax, 8(%ecx)
|
|
; X86-NEXT: movl %edx, 12(%ecx)
|
|
; X86-NEXT: movl %ecx, %eax
|
|
; X86-NEXT: addl $8, %esp
|
|
; X86-NEXT: .cfi_def_cfa_offset 20
|
|
; X86-NEXT: popl %esi
|
|
; X86-NEXT: .cfi_def_cfa_offset 16
|
|
; X86-NEXT: popl %edi
|
|
; X86-NEXT: .cfi_def_cfa_offset 12
|
|
; X86-NEXT: popl %ebx
|
|
; X86-NEXT: .cfi_def_cfa_offset 8
|
|
; X86-NEXT: popl %ebp
|
|
; X86-NEXT: .cfi_def_cfa_offset 4
|
|
; X86-NEXT: retl $4
|
|
%k = mul i128 %t, %u
|
|
ret i128 %k
|
|
}
|