]> git.sesse.net Git - x264/commitdiff
x86inc: Preserve arguments when allocating stack space
authorHenrik Gramner <henrik@gramner.com>
Mon, 12 Oct 2015 18:15:18 +0000 (20:15 +0200)
committerHenrik Gramner <henrik@gramner.com>
Sat, 16 Jan 2016 23:30:12 +0000 (00:30 +0100)
When allocating stack space with a larger alignment than the known stack
alignment a temporary register is used for storing the stack pointer.
Ensure that this isn't one of the registers used for passing arguments.

common/x86/x86inc.asm

index 9e3e7b0c74ff48977ee5d6b998416d9cdb33e598..bde32c5f445e117e5a2b2c0a4df596c717ab2fd9 100644 (file)
@@ -374,8 +374,10 @@ DECLARE_REG_TMP_SIZE 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
         %if %1 != 0 && required_stack_alignment > STACK_ALIGNMENT
             %if %1 > 0
                 %assign regs_used (regs_used + 1)
-            %elif ARCH_X86_64 && regs_used == num_args && num_args <= 4 + UNIX64 * 2
-                %warning "Stack pointer will overwrite register argument"
+            %endif
+            %if ARCH_X86_64 && regs_used < 5 + UNIX64 * 3
+                ; Ensure that we don't clobber any registers containing arguments
+                %assign regs_used 5 + UNIX64 * 3
             %endif
         %endif
     %endif