From patchwork Sun Dec 25 19:24:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Gramner X-Patchwork-Id: 1925 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp753155vsb; Sun, 25 Dec 2016 11:30:48 -0800 (PST) X-Received: by 10.28.191.87 with SMTP id p84mr21672977wmf.63.1482694248116; Sun, 25 Dec 2016 11:30:48 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n4si39864908wmn.72.2016.12.25.11.30.47; Sun, 25 Dec 2016 11:30:48 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gramner-com.20150623.gappssmtp.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3C945689B12; Sun, 25 Dec 2016 21:30:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 877AE68925D for ; Sun, 25 Dec 2016 21:30:36 +0200 (EET) Received: by mail-lf0-f67.google.com with SMTP id d16so11626669lfb.1 for ; Sun, 25 Dec 2016 11:30:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gramner-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=ijYqpCjjTvQM97mHTdiDJAeyVN2oh3EgredKnKh1Em0=; b=uFICxSH/RTBZ3CO2og1Tae0cloaYj7dU/SgdLeTNngtxNmr/ndjaSSgIfLXJKwH7pT xZ2b3bPb7Z4VveEkvOh0ioMusJ56wyUk1nUAHhIlXcsQydn8mQdxN/deZJjvl4WWyDqD RpO/kj0tip7etvpdt44rU8R6HDuxtDQKa/NDsV08VmP0//6TNmek93Kh4BKFnctAyj7c v7VUO/VBJZrKUKE9jUhKAWfa1flkOl76RMIVuGrTtJna4puUuiynR/Q37UHCgQgxT0BT hCJd7nl2ecAAa1/a7rnDYxkyaim6mkhWd3myIVYyBAwDS4ucOtXDdYtnvHHn+fqRurU1 3rYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=ijYqpCjjTvQM97mHTdiDJAeyVN2oh3EgredKnKh1Em0=; b=VqSNHy4x8Xy896yr6ptdprsZ0DMpjpH8XJU/8PzF3XUce/GLh/SvneFJnpnNsqV8Mv SwrwSfXSzGk15SVVIeDLWtIoAwy+ozWwJIDKHjOECEgQV8rkzLKgFoVcTFi92Ww5zfvw Db5OsiWPWQTxfBMfbrlNromJugWS52VuMo6i8NBe19a+1ktypFs1Y48PJhY/D3qp7JEc fNx5v82p7nbczlUi/g4JWvhMlF2NECbfaToM3pnqMDIS1oOK7iCA6BozQUCGcBjAOO5g yF1EgEj1LxKtMKJwcE5n3JR68czGmaMlWYiIHUVK9k4GfaJwwZ/jBWh/rm1eaM67Nhzs 92fQ== X-Gm-Message-State: AIkVDXIL90VbDvGOZZoxl7njFepM7AWcql04jydyZjaMyJ6M6/TW9ywv792IE7ittVjxnw== X-Received: by 10.46.7.26 with SMTP id 26mr10528147ljh.18.1482693910835; Sun, 25 Dec 2016 11:25:10 -0800 (PST) Received: from localhost.localdomain (81-227-53-67-no27.tbcn.telia.com. [81.227.53.67]) by smtp.gmail.com with ESMTPSA id l129sm9878763lfg.47.2016.12.25.11.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Dec 2016 11:25:10 -0800 (PST) From: Henrik Gramner To: ffmpeg-devel@ffmpeg.org, libav-devel@libav.org Date: Sun, 25 Dec 2016 20:24:59 +0100 Message-Id: <1482693899-3704-1-git-send-email-henrik@gramner.com> X-Mailer: git-send-email 2.7.4 Subject: [FFmpeg-devel] [PATCH] x86inc: Avoid using eax/rax for storing the stack pointer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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. --- libavutil/x86/x86inc.asm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm index b2e9c60..128ddc1 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)