From 82a3877126afb9658096f981be0ebe1ac2d18a59 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 24 May 2020 17:52:05 +0000 Subject: [PATCH] + x86: track use of full ymm registers and generate vzeroupper if needed git-svn-id: trunk@45484 - --- compiler/globtype.pas | 4 +++- compiler/i386/cgcpu.pas | 3 +++ compiler/utils/ppuutils/ppudump.pp | 4 +++- compiler/x86_64/cgcpu.pas | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index 1b3bb61473..c828db47cc 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -748,7 +748,9 @@ interface { subroutine needs to load and maintain a tls register } pi_needs_tls, { subroutine uses get_frame } - pi_uses_get_frame + pi_uses_get_frame, + { x86 only: subroutine uses ymm registers, requires vzeroupper call } + pi_uses_ymm ); tprocinfoflags=set of tprocinfoflag; diff --git a/compiler/i386/cgcpu.pas b/compiler/i386/cgcpu.pas index fbc76ecd8b..4b0a684a77 100644 --- a/compiler/i386/cgcpu.pas +++ b/compiler/i386/cgcpu.pas @@ -338,6 +338,9 @@ unit cgcpu; list.concat(tai_regalloc.dealloc(current_procinfo.framepointer,nil)); end; + if pi_uses_ymm in current_procinfo.flags then + list.Concat(taicpu.op_none(A_VZEROUPPER)); + { return from proc } if po_interrupt in current_procinfo.procdef.procoptions then begin diff --git a/compiler/utils/ppuutils/ppudump.pp b/compiler/utils/ppuutils/ppudump.pp index b3e172faf1..60eb2db9fc 100644 --- a/compiler/utils/ppuutils/ppudump.pp +++ b/compiler/utils/ppuutils/ppudump.pp @@ -1641,7 +1641,9 @@ const (mask:pi_needs_tls; str:' uses TLS data pointer '), (mask:pi_uses_get_frame; - str:' uses get_frame') + str:' uses get_frame'), + (mask:pi_uses_ymm; + str:' uses ymm register (x86 only)') ); var procinfooptions : tprocinfoflags; diff --git a/compiler/x86_64/cgcpu.pas b/compiler/x86_64/cgcpu.pas index df755f0718..0310786856 100644 --- a/compiler/x86_64/cgcpu.pas +++ b/compiler/x86_64/cgcpu.pas @@ -423,7 +423,11 @@ unit cgcpu; list.concat(tai_regalloc.dealloc(current_procinfo.framepointer,nil)); end; + if pi_uses_ymm in current_procinfo.flags then + list.Concat(taicpu.op_none(A_VZEROUPPER)); + list.concat(Taicpu.Op_none(A_RET,S_NO)); + if (pi_has_unwind_info in current_procinfo.flags) then begin tcpuprocinfo(current_procinfo).dump_scopes(list);