summaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorHenrik Gramner <henrik@gramner.com>2016-12-20 21:33:12 +0100
committerHenrik Gramner <henrik@gramner.com>2017-01-09 16:00:29 +0100
commitcd09e3b34903db7b7e37fdb4d3e10549bf8b2e82 (patch)
tree2f23471c3bcf7a8c3467c9567376404ae7585322 /libavutil
parent0e8b68a2c4031e25082603ad88711be12210d41f (diff)
x86inc: Avoid using eax/rax for storing the stack pointer
When allocating stack space with an alignment requirement that is larger than the current stack alignment we need to store a copy of the original stack pointer in order to be able to restore it later. If we chose to use another register for this purpose we should not pick eax/rax since it can be overwritten as a return value.
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/x86/x86inc.asm7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
index b2e9c60195..128ddc1089 100644
--- a/libavutil/x86/x86inc.asm
+++ b/libavutil/x86/x86inc.asm
@@ -385,7 +385,14 @@ DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
%ifnum %1
%if %1 != 0 && required_stack_alignment > STACK_ALIGNMENT
%if %1 > 0
+ ; Reserve an additional register for storing the original stack pointer, but avoid using
+ ; eax/rax for this purpose since it can potentially get overwritten as a return value.
%assign regs_used (regs_used + 1)
+ %if ARCH_X86_64 && regs_used == 7
+ %assign regs_used 8
+ %elif ARCH_X86_64 == 0 && regs_used == 1
+ %assign regs_used 2
+ %endif
%endif
%if ARCH_X86_64 && regs_used < 5 + UNIX64 * 3
; Ensure that we don't clobber any registers containing arguments. For UNIX64 we also preserve r6 (rax)