From patchwork Tue Oct 25 12:48:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp2782679pzb; Tue, 25 Oct 2022 05:48:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7bRBcgL9DmQ4N86WOmeaH7qXOj8u4kMFyL/kP2aTwdcEYLT3ZHXCMrALqI9Fm05cgjsCM6 X-Received: by 2002:a17:907:3d91:b0:78d:f675:5659 with SMTP id he17-20020a1709073d9100b0078df6755659mr31656310ejc.92.1666702138967; Tue, 25 Oct 2022 05:48:58 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f13-20020a056402354d00b0045be16903d0si3160167edd.310.2022.10.25.05.48.58; Tue, 25 Oct 2022 05:48:58 -0700 (PDT) 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=@outlook.com header.s=selector1 header.b=EfBgMWxK; arc=fail (body hash mismatch); 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1ADD168BABD; Tue, 25 Oct 2022 15:48:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-oln040092069086.outbound.protection.outlook.com [40.92.69.86]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 974FB68BA36 for ; Tue, 25 Oct 2022 15:48:47 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PK8xq3l/8vYaVHsnE1s7nM298QYnEWcIRk6DPF0Z0Bdz/ygTStWdwKkSffdW/mq51yPLvBRS15aafbNKEzLOufq+zlibPWcd38DbNRGI9o2NH0Nfioy9MyLvQuGml7ZDo/FEG8pitxV4NNCVoACabVmAtJPb9SHcy2ay/s+sxuWgbv+wVM2YCmYqHVantlvAA947dXV/ixVAVOwbv1+tKbBO4uqtrQM7W26bJ0GEVFB5+kBmkVWApC+0ZYCLk8qWre3RLAegN6Nxt059MapSyCqCMTb5AUy2PAFltwE7ZcOrsRuC1SXSuTfGGhbGNDwVIz3ObokW3hd3XLo9L6QNMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0fWCdPxy82WDH8UMcWiig+a/q+JxxNij+wwxZPVkAcs=; b=UE48TzW0u376JL0Q/GsIxdKFj9sKxNNCiRyNx6QQkPCgJvG/UvJmHLQcTjrvLjRsn0sBFIiC/ZT5pf8NjisCoS+pIuZo8QMrWSWEU/937lf0EqJjjHVyFglaZwSfzXllcJGwsNQH4D34dTkhDYNsRp/fK3mpQwhdglCNaDNJbQPs8m2nzajeMxNBw1J5sUDYjOVVgXxYJFXE0dPHU4Vzxsi8ugNNU4j82cujT+aueB/WONjegnfTDcJf8FvP7SfKkbljFVZbmmAHB2xSBWAvxgjcQ8DWO4d3Oyn59bD6TiJtSIo9OCPixfNgwOLXM+KQBmNWxsZzpqtmzO+lkN1tVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0fWCdPxy82WDH8UMcWiig+a/q+JxxNij+wwxZPVkAcs=; b=EfBgMWxKPYue6KPuz8WEZs/i6SbwlMfam7wD8YOwDMwBhnLBDRFtzGZQav2ul4qe16UdaDuv6oWLuZKSKraMacFf6EMMKj5TGwzjQUGWZ8Ctl++GWqZGpysXlrDP7T0hgUwHLM5t1KFEuN+hd2FpC8mGQUECUIPY+aF28aEQtiXen0yrpHE9nixZrz76c7gsoeOsAu8tl3QYw2sr8ONrJDPVdUVsMyexC7egXVKpWaZ1p8wPWY3I6JQZOMeg9L4KQFrPA1DWgrw7mXScII+BO4+4qjdwxsmgOc0NLhsqGzeLjszLqChMJipRvP5qiw+BiwxOanStuSVW2bfKIHrkHw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by GV1P250MB0906.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:95::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.23; Tue, 25 Oct 2022 12:48:45 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe%7]) with mapi id 15.20.5709.015; Tue, 25 Oct 2022 12:48:45 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 25 Oct 2022 14:48:48 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [zIK/vHLWKDuuwhiOgje2aoBX+Lci2EDSFAEcFN9bjGI=] X-ClientProxiedBy: FR3P281CA0179.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::16) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20221025124848.727734-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|GV1P250MB0906:EE_ X-MS-Office365-Filtering-Correlation-Id: c5aee8a2-c1d8-4d83-8168-08dab68740fb X-MS-Exchange-SLBlob-MailProps: iS5pQZgsAQDfwizeNzvxjb11Q3OyfEpJKFsoqTG9seI58iSi319iFlNN7xhVClYyL4fihZrFAYM+eTnbDl7wGsQauOW5z5UXy0hWkMs/3FPtrchkeMN6bGZC1zrYMRnkMUMkpS+5zCG7kzpsJsPe++wQooGRFMnzL0TeJ3W8TUtYuyfDEm8VOf3lLptZEnxnxwFYxCtbrti1tBllQj6IcePYsiWpdhkT/o/sVdbSXOGuCXzNXCd2Cmm3SKZ1jfYCbAMRnK57UdBPgQUFD+ZwjzZbeYMe+3ErD4Ye9O0WW1GdtQrZ0M9r7sjxJguRBl2Q5SEemjuUEujlmKD+EFTjpM4i0CsdeCT/WP3/VSohZllrb9LNz43SVTPL6bJkdFt2oaV8B/kfGZFUeGJQa9wZzfPxkd+pR3R/3hYFgA9aKMHrKvTDSruOCT75sbZZj0AyWwL4l9Hy4gtvAxAZYKsI6cJYPNxMhW6nXI61ur7YKR+kVYSm8/oNtKdTtoZDzick398kkMHbk27TMFE3XrDTFAL6slU2IwImFr2RVraBUWg+bVS13WoqJYTxirfi9Q9IG/UZjgnIO+yvKIJrgztlpcomgs2MmRHNSGjNIGSp0J3kvCmdPxK6hjF+myOXRtnM4vW8XIs9iHWivEBYCWWFkkh00sp+od3nTGELhLu/eE7vqTiLIHxLpQxCZVg/nBNS2QukiueV3TAXCbPzrQ3d+/z2s1Tjx1fdfofTnwe3d8raYqgCQwfQiQca48rm4C2ENA5gnSwakuXys4bLGKISF3tkFHAzBpt4BOeTNsie7v5zrqhKi0eK18i1zWgF/98R X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MvgjNO7tXybCfjlu1XywsAzKT8bUSUuuTAtRfaGTi4XRtduw/5Fuxpt0WAn0t017r49nk7av2pSnXvLtaxL/iMBwnAKdh/BtPgNvRyXmHBVNDk/1ciOUO18x+BdUSXUa7lnMsULRMt6HHWHEcanjCxvxZmfYUObRuUJl2y43yGb0HWjr/RzBZ0zc29MAFOAMqgHJjqbhsI1djB7QRGVkJihrBLGT9iueVzi4b+VvrqfJRA8izRm2+sUu972aDrYYPg1+IBL9dV6Tauxx4pIiyhOYp7ATSa0b59r1X+duwHORYohowO+NJNHZTZ5t4z0rL3ZQmwi/TIY4JgV/Od2X+2eoAxqsOFbGXsCPE035orvuGn2TfUUhuC8gUqjTRgoGgk1YFLMlflJrWzcFUII01fYbEZ+Hn/PAVdsA1GZZ66x0nqukoQwDtXH8K/1M6X10GN186mE2jcwbgDWK7wWIRFVMjGGCchQ+go+TvDOdPjAzjJXALyibvSw2ph+ZumMlP/YFZf33+aYf3cM9J25YL6D0GXMVb55zH7mnwNZv+9uw8wPTmSHmn1+7Yt0MpcloYWVN/F+UI9XN+xAngPapLPnUjutxWnAQ0UldPFkO4K9kp3mWnlDub5Upbk1T+mu2w1DyhaX2BnbPj96zWI2o7b2dFnSE7MNbzv9ToGVio5GLLJlyMhdM/jYHpsfQaHa+ X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RI8RfyX2ydnp7+KTNgiRNZYEW1o60riHmP8TsvmRjACpFgoctx/9nyuaG00TF4MOUqO8x9HDCSTuRyGwy25HmDCXy35bOZoPViWblE/HgSK8YEyW9eRI53UKGIS/MNclSmkdUOiiGlsnYM6tf8CjFqPjWwhizgtvvKlQLDX+Wf1UUHDs7BMpr6gUqsgB+dJMHmXHrjBB9Vf0RgQwTOFDvVp8fqXrKCf5spYDOlqDhhaFS3wjqwofa6x5cok9ny7U7gf/7keJ69+WXm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look.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5aee8a2-c1d8-4d83-8168-08dab68740fb X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 12:48:45.6223 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P250MB0906 Subject: [FFmpeg-devel] [PATCH] avcodec/svq1enc: Workaround GCC bug 102513 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Josh Dekker , Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Hd1lex7zBeiN GCC 11 has a bug: When it creates clones of recursive functions (to inline some parameters), it clones a recursive function eight times by default, even when this exceeds the recursion depth. This happens with encode_block() in libavcodec/svq1enc.c where a parameter level is always in the range 0..5; but GCC 11 also creates functions corresponding to level UINT_MAX and UINT_MAX - 1 (on -O3; -O2 is fine). Using such levels would produce undefined behaviour and because of this GCC emits bogus -Warray-bounds warnings for these clones. Since commit d08b2900a9f0935959303da668cb00a8a7245228, certain symbols that are accessed like ff_svq1_inter_multistage_vlc[level] are declared with hidden visibility, which allows compilers to bake the offset implied by level into the instructions if level is a compile-time constant as it is in the clones. Yet this leads to insane offsets for level == UINT_MAX which can be incompatible with the supported offset ranges of relocations. This happens in the small code model (the default code model for AArch64). This commit therefore works around this bug by disabling cloning recursive functions for GCC 10 and 11. GCC 10 is affected by the underlying bug (see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102513), so the workaround also targets it, although it only produces three versions of encode_block(), so it does not seem to trigger the actual issue here. The issue has been mitigated in GCC 12.1 (it no longer creates clones for impossible values; see also commit 1cb7fd317c84117bbb13b14851d62f77f57bb9ce), so the workaround does not target it. Reported-by: Josh Dekker Signed-off-by: Andreas Rheinhardt --- libavcodec/svq1enc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 75adbe7ea0..7c9430a137 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -46,6 +46,12 @@ #include "libavutil/frame.h" #include "libavutil/mem_internal.h" +// Workaround for GCC bug 102513 +#if AV_GCC_VERSION_AT_LEAST(10, 0) && AV_GCC_VERSION_AT_MOST(12, 0) \ + && !defined(__clang__) && !defined(__INTEL_COMPILER) +#pragma GCC optimize ("no-ipa-cp-clone") +#endif + typedef struct SVQ1EncContext { /* FIXME: Needed for motion estimation, should not be used for anything * else, the idea is to make the motion estimation eventually independent