From patchwork Sun Nov 12 16:24:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Thomas_K=C3=B6ppe?= X-Patchwork-Id: 6013 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.94 with SMTP id m30csp1214243jah; Sun, 12 Nov 2017 08:30:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMZcCAEGSC64GbqBWNw0Ou07sk/THXJ+h3I4XCG6ACctsPiU5oxiDHFvaidnPPBVxvcpoRbr X-Received: by 10.28.69.210 with SMTP id l79mr4569215wmi.117.1510504209837; Sun, 12 Nov 2017 08:30:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510504209; cv=none; d=google.com; s=arc-20160816; b=qJv+vHAVdST+62s+AKf416IAKgVYMcnyKtHBC4qwg6OB8MbYX/WTukJuUZIzMVkzJp ZAk85ZWrKjYnSd6BvAZt2D5okYMkYy8HRdKl8gGzFF4J/1uOhhB3AiEYSaJ74UElatWJ d/1dC2Ndp0uvu3LFhRMaWwK4F9uZ62Vkmsw/ZER5zQItYwRuFDeput4+oz63WwbazBPP V1bN8WLWUba0yiP9MybnmAlwT88z/8v1V0u0jkspWEV8fR8I0zExrxeYSruYY7tw8jCK i64ukMbX1X6zeqb14C8qvDjJoy3mOWxHrEfJmjaZsAlPzzk3OltlO5MJhE+6/fIJiNlV hGlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=Qp5ZgxctvoGHbXOlf7zx6YGs+u0YoBsxPBKnvgGKX5c=; b=giNQWo5YPFmW7Bwzvnw4naYZCL3WchQbsFuGQAZ8Yay1wPhd5UDFS07Xu9eM0SmZPH wNd7miuT03aoToeTluwzdCJVSef9a6WMOpCOKl2l4mnaT4oLSkswGuX+6Uq2DlRTuV86 /nQM9XaDRkor9BZojbMarGxyNrO3biSZFbSLzAmoLNDStoVB058EavEznKtfcsSujWPe /EA0QhVBQpdUj5OFciK7blFwv5BaaIo3YxGP3s1U641UiBagiJv7waoeuPEVQ4EMyTHI nLQmUIcvbTOV6UA2EgPT/7Zp5qNiYK04UJ5lt006Sw3jZ+udXV3ElHC5j90jd9m0AmhA ikBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=r1u1goir; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r13si4490760wmf.217.2017.11.12.08.30.09; Sun, 12 Nov 2017 08:30:09 -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=@google.com header.s=20161025 header.b=r1u1goir; 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 436F168A468; Sun, 12 Nov 2017 18:29:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5FFD1688354 for ; Sun, 12 Nov 2017 18:29:48 +0200 (EET) Received: by mail-wm0-f68.google.com with SMTP id b189so4000871wmd.0 for ; Sun, 12 Nov 2017 08:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0ESTLuy+ORboxdfxSzuj79nc1wicsZgBZK2IasLWlzw=; b=r1u1goirTIysQPvP/1h7CQKV8ssa9fgvuVnqKYg9f1dzM8BKuqfnjcCvP3G7mQhs8C aT/4ii5zDRQQgTTgD7f6d8miI6b302Hxq+ztZd5qnnIM2ne9ez+5pcB3WEbLM+KACMo8 R6rRksYr3QWA/yZITN9JZKNluKJn7TjTESisYmeBLiH3s1vzlhJpPpdF0KyAYt3a7zw/ EFT4Pu19CCEQWBHb3b43VLjlo4HlbT4PXbc2FjI7sX2v4S5PhMMgtc+N22qiJCkN6HMt GCSM4i+fnLI443gblRXeTc/5cVWan+W2+UZfhU44rugk3j8Q6MYqYi4m0jyRWjjQ4kqI 6Bnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0ESTLuy+ORboxdfxSzuj79nc1wicsZgBZK2IasLWlzw=; b=hAh99+gy2X5qKqi/+CRkFd8eZJ4RWy+EgtszT6kc5L7CEThYRT3rGQ82ebZIa3FVrh GJJlyFnSZkUa1B0z/AFTPsU8tT+WTAxH3JGk7w2JrR4HJ+hs+WOImjDcIL3vU24yJzH7 OeIeVP4ZMVwGTShOUhatwAcDtALLHlQyN1mMX3beZvnEEb0uwwR21E+pdZwM+XnnqXjn 5GHlw/Ah3em3EeA+hbF1/Z+U73LR+egNENB/b2I2uHTrJNS5Eyf1/Y5C/hvqMt6WsyxJ bb/g2yjMGRkoHeqjO1ob42hVUvsnegk3jPEQkQfNhmWv3ZLzxMXtsskZr9fRXecQyrTh 24dg== X-Gm-Message-State: AJaThX4MPg0Jjb2j/cXtejI7LWcJYeJRffKT+9hk9sw6c3dRbLiiwKFb uzLAEFiZ2BWFyA85kSfMobIPOytjjGY= X-Received: by 10.80.212.8 with SMTP id t8mr9172604edh.89.1510503882418; Sun, 12 Nov 2017 08:24:42 -0800 (PST) Received: from tkoeppe.lon.corp.google.com ([2a00:79e0:d:207:f8e5:a2e3:b8ee:23e8]) by smtp.gmail.com with ESMTPSA id b36sm12762129edd.67.2017.11.12.08.24.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Nov 2017 08:24:41 -0800 (PST) From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Nov 2017 16:24:37 +0000 Message-Id: <20171112162437.18878-1-tkoeppe@google.com> X-Mailer: git-send-email 2.15.0.448.gf294e3d99a-goog In-Reply-To: <891adff0-0649-d42b-8b4a-5fc158064aa4@gmail.com> References: <891adff0-0649-d42b-8b4a-5fc158064aa4@gmail.com> Subject: [FFmpeg-devel] [PATCH] Fix missing used attribute for inline assembly variables 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 Cc: =?UTF-8?q?Thomas=20K=C3=B6ppe?= MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Variables used in inline assembly need to be marked with attribute((used)). Static constants already were, via the define of DECLARE_ASM_CONST. But DECLARE_ALIGNED does not add this attribute, and some of the variables defined with it are const only used in inline assembly, and therefore appeared dead. This change adds a macro DECLARE_ASM_ALIGNED that marks variables as used. This change makes FFMPEG work with Clang's ThinLTO. --- libavcodec/cabac.c | 2 +- libavcodec/x86/constants.c | 20 ++++++++++---------- libavutil/mem.h | 17 +++++++++++++++++ libswscale/x86/swscale.c | 12 ++++++------ 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c index dd2b057c6d..e51139de3b 100644 --- a/libavcodec/cabac.c +++ b/libavcodec/cabac.c @@ -32,7 +32,7 @@ #include "cabac.h" #include "cabac_functions.h" -const uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63] = { +DECLARE_ASM_ALIGNED(1, const uint8_t, ff_h264_cabac_tables)[512 + 4*2*64 + 4*64 + 63] = { 9,8,7,7,6,6,6,6,5,5,5,5,5,5,5,5, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, diff --git a/libavcodec/x86/constants.c b/libavcodec/x86/constants.c index 11002ee61e..47905c74a1 100644 --- a/libavcodec/x86/constants.c +++ b/libavcodec/x86/constants.c @@ -26,23 +26,23 @@ DECLARE_ALIGNED(32, const ymm_reg, ff_pw_1) = { 0x0001000100010001ULL, 0x000 0x0001000100010001ULL, 0x0001000100010001ULL }; DECLARE_ALIGNED(32, const ymm_reg, ff_pw_2) = { 0x0002000200020002ULL, 0x0002000200020002ULL, 0x0002000200020002ULL, 0x0002000200020002ULL }; -DECLARE_ALIGNED(16, const xmm_reg, ff_pw_3) = { 0x0003000300030003ULL, 0x0003000300030003ULL }; -DECLARE_ALIGNED(32, const ymm_reg, ff_pw_4) = { 0x0004000400040004ULL, 0x0004000400040004ULL, +DECLARE_ASM_ALIGNED(16, const xmm_reg, ff_pw_3) = { 0x0003000300030003ULL, 0x0003000300030003ULL }; +DECLARE_ASM_ALIGNED(32, const ymm_reg, ff_pw_4) = { 0x0004000400040004ULL, 0x0004000400040004ULL, 0x0004000400040004ULL, 0x0004000400040004ULL }; -DECLARE_ALIGNED(16, const xmm_reg, ff_pw_5) = { 0x0005000500050005ULL, 0x0005000500050005ULL }; +DECLARE_ASM_ALIGNED(16, const xmm_reg, ff_pw_5) = { 0x0005000500050005ULL, 0x0005000500050005ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_8) = { 0x0008000800080008ULL, 0x0008000800080008ULL }; -DECLARE_ALIGNED(16, const xmm_reg, ff_pw_9) = { 0x0009000900090009ULL, 0x0009000900090009ULL }; +DECLARE_ASM_ALIGNED(16, const xmm_reg, ff_pw_9) = { 0x0009000900090009ULL, 0x0009000900090009ULL }; DECLARE_ALIGNED(8, const uint64_t, ff_pw_15) = 0x000F000F000F000FULL; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_16) = { 0x0010001000100010ULL, 0x0010001000100010ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_17) = { 0x0011001100110011ULL, 0x0011001100110011ULL }; -DECLARE_ALIGNED(16, const xmm_reg, ff_pw_18) = { 0x0012001200120012ULL, 0x0012001200120012ULL }; +DECLARE_ASM_ALIGNED(16, const xmm_reg, ff_pw_18) = { 0x0012001200120012ULL, 0x0012001200120012ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_20) = { 0x0014001400140014ULL, 0x0014001400140014ULL }; DECLARE_ALIGNED(16, const xmm_reg, ff_pw_32) = { 0x0020002000200020ULL, 0x0020002000200020ULL }; -DECLARE_ALIGNED(8, const uint64_t, ff_pw_42) = 0x002A002A002A002AULL; -DECLARE_ALIGNED(8, const uint64_t, ff_pw_53) = 0x0035003500350035ULL; -DECLARE_ALIGNED(16, const xmm_reg, ff_pw_64) = { 0x0040004000400040ULL, 0x0040004000400040ULL }; -DECLARE_ALIGNED(8, const uint64_t, ff_pw_96) = 0x0060006000600060ULL; -DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_pw_42) = 0x002A002A002A002AULL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_pw_53) = 0x0035003500350035ULL; +DECLARE_ASM_ALIGNED(16, const xmm_reg, ff_pw_64) = { 0x0040004000400040ULL, 0x0040004000400040ULL }; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_pw_96) = 0x0060006000600060ULL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL; DECLARE_ALIGNED(32, const ymm_reg, ff_pw_255) = { 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL, 0x00ff00ff00ff00ffULL }; DECLARE_ALIGNED(32, const ymm_reg, ff_pw_256) = { 0x0100010001000100ULL, 0x0100010001000100ULL, diff --git a/libavutil/mem.h b/libavutil/mem.h index e5ca8299dc..9e344bd2c3 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -73,6 +73,19 @@ * @param v Name of the variable */ +/** + * @def DECLARE_ASM_ALIGNED(n,t,v) + * Declare an aligned variable appropriate for use in inline assembly code. + * + * @code{.c} + * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); + * @endcode + * + * @param n Minimum alignment in bytes + * @param t Type of the variable (or array element) + * @param v Name of the variable + */ + /** * @def DECLARE_ASM_CONST(n,t,v) * Declare a static constant aligned variable appropriate for use in inline @@ -89,18 +102,22 @@ #if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v #elif defined(__DJGPP__) #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v #elif defined(__GNUC__) || defined(__clang__) #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v #elif defined(_MSC_VER) #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v #else #define DECLARE_ALIGNED(n,t,v) t v + #define DECLARE_ASM_ALIGNED(n,t,v) t v #define DECLARE_ASM_CONST(n,t,v) static const t v #endif diff --git a/libswscale/x86/swscale.c b/libswscale/x86/swscale.c index 869e7fb176..7dc2d70574 100644 --- a/libswscale/x86/swscale.c +++ b/libswscale/x86/swscale.c @@ -53,13 +53,13 @@ DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL; DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL; DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL; -DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL; -DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL; -DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL; -DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL; -DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL; -DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL; +DECLARE_ASM_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL; //MMX versions