forked from llvm/llvm-project
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86] Only force FP usage in the presence of pushf/popf on Win64
This ensures that the Windows unwinder will work at every instruction boundary, and allows other targets to read and write flags without setting up a frame pointer. Fixes llvmGH-46875 Differential Revision: https://reviews.llvm.org/D119391
- Loading branch information
Showing
3 changed files
with
51 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,54 @@ | ||
; RUN: llc -verify-machineinstrs < %s | FileCheck %s | ||
target triple = "x86_64-pc-win32" | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -verify-machineinstrs -mtriple x86_64-linux < %s | FileCheck %s | ||
; RUN: llc -verify-machineinstrs -mtriple x86_64-windows < %s | FileCheck %s --check-prefix=WIN64 | ||
|
||
declare i64 @llvm.x86.flags.read.u64() | ||
declare void @llvm.x86.flags.write.u64(i64) | ||
|
||
define i64 @read_flags() { | ||
; CHECK-LABEL: read_flags: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: pushfq | ||
; CHECK-NEXT: popq %rax | ||
; CHECK-NEXT: retq | ||
; | ||
; WIN64-LABEL: read_flags: | ||
; WIN64: # %bb.0: # %entry | ||
; WIN64-NEXT: pushq %rbp | ||
; WIN64-NEXT: .seh_pushreg %rbp | ||
; WIN64-NEXT: movq %rsp, %rbp | ||
; WIN64-NEXT: .seh_setframe %rbp, 0 | ||
; WIN64-NEXT: .seh_endprologue | ||
; WIN64-NEXT: pushfq | ||
; WIN64-NEXT: popq %rax | ||
; WIN64-NEXT: popq %rbp | ||
; WIN64-NEXT: retq | ||
; WIN64-NEXT: .seh_endproc | ||
entry: | ||
%flags = call i64 @llvm.x86.flags.read.u64() | ||
ret i64 %flags | ||
} | ||
|
||
; CHECK-LABEL: read_flags: | ||
; CHECK: pushq %rbp | ||
; CHECK: .seh_pushreg %rbp | ||
; CHECK: movq %rsp, %rbp | ||
; CHECK: .seh_setframe %rbp, 0 | ||
; CHECK: .seh_endprologue | ||
; CHECK-NEXT: pushfq | ||
; CHECK-NEXT: popq %rax | ||
; CHECK-NEXT: popq %rbp | ||
|
||
define void @write_flags(i64 %arg) { | ||
; CHECK-LABEL: write_flags: | ||
; CHECK: # %bb.0: # %entry | ||
; CHECK-NEXT: pushq %rdi | ||
; CHECK-NEXT: popfq | ||
; CHECK-NEXT: retq | ||
; | ||
; WIN64-LABEL: write_flags: | ||
; WIN64: # %bb.0: # %entry | ||
; WIN64-NEXT: pushq %rbp | ||
; WIN64-NEXT: .seh_pushreg %rbp | ||
; WIN64-NEXT: movq %rsp, %rbp | ||
; WIN64-NEXT: .seh_setframe %rbp, 0 | ||
; WIN64-NEXT: .seh_endprologue | ||
; WIN64-NEXT: pushq %rcx | ||
; WIN64-NEXT: popfq | ||
; WIN64-NEXT: popq %rbp | ||
; WIN64-NEXT: retq | ||
; WIN64-NEXT: .seh_endproc | ||
entry: | ||
call void @llvm.x86.flags.write.u64(i64 %arg) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: write_flags: | ||
; CHECK: pushq %rbp | ||
; CHECK: .seh_pushreg %rbp | ||
; CHECK: movq %rsp, %rbp | ||
; CHECK: .seh_setframe %rbp, 0 | ||
; CHECK: .seh_endprologue | ||
; CHECK-NEXT: pushq %rcx | ||
; CHECK-NEXT: popfq | ||
; CHECK-NEXT: popq %rbp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters