mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +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
48 lines
1.5 KiB
LLVM
48 lines
1.5 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
; RUN: llc < %s -fast-isel -mtriple=i686-unknown-unknown -O0 -mcpu=skx | FileCheck %s
|
|
|
|
@c = external global i8, align 1
|
|
|
|
; Function Attrs: noinline nounwind
|
|
define void @_Z1av() {
|
|
; CHECK-LABEL: _Z1av:
|
|
; CHECK: # %bb.0: # %entry
|
|
; CHECK-NEXT: subl $2, %esp
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 6
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
; CHECK-NEXT: movb %al, %cl
|
|
; CHECK-NEXT: movb c, %dl
|
|
; CHECK-NEXT: xorb $-1, %dl
|
|
; CHECK-NEXT: testb $1, %dl
|
|
; CHECK-NEXT: movb %cl, (%esp) # 1-byte Spill
|
|
; CHECK-NEXT: jne .LBB0_1
|
|
; CHECK-NEXT: jmp .LBB0_2
|
|
; CHECK-NEXT: .LBB0_1: # %land.rhs
|
|
; CHECK-NEXT: xorl %eax, %eax
|
|
; CHECK-NEXT: movb %al, %cl
|
|
; CHECK-NEXT: movb %cl, (%esp) # 1-byte Spill
|
|
; CHECK-NEXT: jmp .LBB0_2
|
|
; CHECK-NEXT: .LBB0_2: # %land.end
|
|
; CHECK-NEXT: movb (%esp), %al # 1-byte Reload
|
|
; CHECK-NEXT: andb $1, %al
|
|
; CHECK-NEXT: movb %al, {{[0-9]+}}(%esp)
|
|
; CHECK-NEXT: addl $2, %esp
|
|
; CHECK-NEXT: .cfi_def_cfa_offset 4
|
|
; CHECK-NEXT: retl
|
|
entry:
|
|
%b = alloca i8, align 1
|
|
%0 = load i8, i8* @c, align 1
|
|
%tobool = trunc i8 %0 to i1
|
|
%lnot = xor i1 %tobool, true
|
|
br i1 %lnot, label %land.rhs, label %land.end
|
|
|
|
land.rhs: ; preds = %entry
|
|
br label %land.end
|
|
|
|
land.end: ; preds = %land.rhs, %entry
|
|
%1 = phi i1 [ false, %entry ], [ false, %land.rhs ]
|
|
%conv = zext i1 %1 to i8
|
|
store i8 %conv, i8* %b, align 1
|
|
ret void
|
|
}
|