mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
Reland r317100 with minor fix regarding ComputeCommonTailLength function in BranchFolding.cpp. Skipping top CFI instructions block needs to executed on several more return points in ComputeCommonTailLength(). Original r317100 message: "Correct dwarf unwind information in function epilogue for X86" 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 - 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. Changed CFI instructions so that they: - are duplicable - are not counted as instructions when tail duplicating or tail merging - can be compared as equal Added CFIInstrInserter pass: - analyzes each basic block to determine cfa offset and register 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317579 91177308-0d34-0410-b5e6-96231b3b80d8
142 lines
3.4 KiB
LLVM
142 lines
3.4 KiB
LLVM
; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -fixup-byte-word-insts=0 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWOFF %s
|
|
; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -fixup-byte-word-insts=1 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWON %s
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -fixup-byte-word-insts=0 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWOFF %s
|
|
; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -fixup-byte-word-insts=1 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWON %s
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -fixup-byte-word-insts=0 | \
|
|
; RUN: FileCheck -check-prefix=DARWIN -check-prefix=DARWIN-BWOFF %s
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -fixup-byte-word-insts=1 | \
|
|
; RUN: FileCheck -check-prefix=DARWIN -check-prefix=DARWIN-BWON %s
|
|
|
|
|
|
@x = common global i32 0, align 4
|
|
|
|
define zeroext i1 @unsigned_i1() {
|
|
entry:
|
|
%0 = load i32, i32* @x
|
|
%cmp = icmp eq i32 %0, 42
|
|
ret i1 %cmp
|
|
|
|
; Unsigned i1 return values are not extended.
|
|
; CHECK-LABEL: unsigned_i1:
|
|
; CHECK: cmp
|
|
; CHECK-NEXT: sete
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define zeroext i8 @unsigned_i8() {
|
|
entry:
|
|
%0 = load i32, i32* @x
|
|
%cmp = icmp eq i32 %0, 42
|
|
%retval = zext i1 %cmp to i8
|
|
ret i8 %retval
|
|
|
|
; Unsigned i8 return values are not extended.
|
|
; CHECK-LABEL: unsigned_i8:
|
|
; CHECK: cmp
|
|
; CHECK-NEXT: sete
|
|
; CHECK-NEXT: ret
|
|
|
|
; Except on Darwin, for legacy reasons.
|
|
; DARWIN-LABEL: unsigned_i8:
|
|
; DARWIN: xorl
|
|
; DARWIN-NEXT: cmp
|
|
; DARWIN-NEXT: sete
|
|
; DARWIN-NEXT: ret
|
|
}
|
|
|
|
define signext i8 @signed_i8() {
|
|
entry:
|
|
%0 = load i32, i32* @x
|
|
%cmp = icmp eq i32 %0, 42
|
|
%retval = zext i1 %cmp to i8
|
|
ret i8 %retval
|
|
|
|
; Signed i8 return values are not extended.
|
|
; CHECK-LABEL: signed_i8:
|
|
; CHECK: cmp
|
|
; CHECK-NEXT: sete
|
|
; CHECK-NEXT: ret
|
|
|
|
; Except on Darwin, for legacy reasons.
|
|
; DARWIN-LABEL: signed_i8:
|
|
; DARWIN: xorl
|
|
; DARWIN-NEXT: cmp
|
|
; DARWIN-NEXT: sete
|
|
; DARWIN-NEXT: ret
|
|
}
|
|
|
|
@a = common global i16 0
|
|
@b = common global i16 0
|
|
define zeroext i16 @unsigned_i16() {
|
|
entry:
|
|
%0 = load i16, i16* @a
|
|
%1 = load i16, i16* @b
|
|
%add = add i16 %1, %0
|
|
ret i16 %add
|
|
|
|
; i16 return values are not extended.
|
|
; CHECK-LABEL: unsigned_i16:
|
|
; BWOFF: movw
|
|
; BWON: movzwl
|
|
; CHECK-NEXT: addw
|
|
; CHECK-NEXT: ret
|
|
|
|
; Except on Darwin, for legacy reasons.
|
|
; DARWIN-LABEL: unsigned_i16:
|
|
; DARWIN-BWOFF: movw
|
|
; DARWIN-BWON: movzwl
|
|
; DARWIN-NEXT: addw
|
|
; DARWIN-NEXT: movzwl
|
|
; DARWIN-NEXT: ret
|
|
}
|
|
|
|
|
|
define i32 @use_i1() {
|
|
entry:
|
|
%0 = call i1 @unsigned_i1();
|
|
%1 = zext i1 %0 to i32
|
|
ret i32 %1
|
|
|
|
; The high 24 bits of %eax from a function returning i1 are undefined.
|
|
; CHECK-LABEL: use_i1:
|
|
; CHECK: call
|
|
; CHECK-NEXT: movzbl
|
|
; CHECK-NEXT: {{pop|add}}
|
|
; CHECK-NEXT: .cfi_def_cfa_offset {{4|8}}
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define i32 @use_i8() {
|
|
entry:
|
|
%0 = call i8 @unsigned_i8();
|
|
%1 = zext i8 %0 to i32
|
|
ret i32 %1
|
|
|
|
; The high 24 bits of %eax from a function returning i8 are undefined.
|
|
; CHECK-LABEL: use_i8:
|
|
; CHECK: call
|
|
; CHECK-NEXT: movzbl
|
|
; CHECK-NEXT: {{pop|add}}
|
|
; CHECK-NEXT: .cfi_def_cfa_offset {{4|8}}
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define i32 @use_i16() {
|
|
entry:
|
|
%0 = call i16 @unsigned_i16();
|
|
%1 = zext i16 %0 to i32
|
|
ret i32 %1
|
|
|
|
; The high 16 bits of %eax from a function returning i16 are undefined.
|
|
; CHECK-LABEL: use_i16:
|
|
; CHECK: call
|
|
; CHECK-NEXT: movzwl
|
|
; CHECK-NEXT: {{pop|add}}
|
|
; CHECK-NEXT: .cfi_def_cfa_offset {{4|8}}
|
|
; CHECK-NEXT: ret
|
|
}
|