PR #22392 opened by Martin Storsjö (mstorsjo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22392
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22392.patch

This fixes compiling with MSVC for aarch64 after
510999f6b07b6996983c7ef24c3cf41a06241261.

While MSVC does do dead code elimintation for function references
within e.g. "if (0)", it doesn't do that for functions referenced
within a static function, even if that static function itself ends
up not used.

A reproduction example:

    void missing(void);
    void (*func_ptr)(void);

    static void wrapper(void) {
        missing();
    }

    void init(int cpu_flags) {
        if (0) {
            func_ptr = wrapper;
        }
    }

If "wrapper" is entirely unreferenced, then MSVC doesn't produce
any reference to the symbol "missing". Also, if we do
"func_ptr = missing;" then the reference to missing also is
eliminated. But for the case of referencing the function in a
static function, even if the reference to the static function can
be eliminated, then MSVC does keep the reference to the symbol.


From 74cfcd1c6912f3cdd74d0ba58c316b04a11691f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
Date: Thu, 5 Mar 2026 11:52:03 +0200
Subject: [PATCH] aarch64/vvc: Fix DCE undefined references with MSVC

This fixes compiling with MSVC for aarch64 after
510999f6b07b6996983c7ef24c3cf41a06241261.

While MSVC does do dead code elimintation for function references
within e.g. "if (0)", it doesn't do that for functions referenced
within a static function, even if that static function itself ends
up not used.

A reproduction example:

    void missing(void);
    void (*func_ptr)(void);

    static void wrapper(void) {
        missing();
    }

    void init(int cpu_flags) {
        if (0) {
            func_ptr = wrapper;
        }
    }

If "wrapper" is entirely unreferenced, then MSVC doesn't produce
any reference to the symbol "missing". Also, if we do
"func_ptr = missing;" then the reference to missing also is
eliminated. But for the case of referencing the function in a
static function, even if the reference to the static function can
be eliminated, then MSVC does keep the reference to the symbol.
---
 libavcodec/aarch64/vvc/alf_template.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/aarch64/vvc/alf_template.c 
b/libavcodec/aarch64/vvc/alf_template.c
index 0b63879c1f..03bf9056bb 100644
--- a/libavcodec/aarch64/vvc/alf_template.c
+++ b/libavcodec/aarch64/vvc/alf_template.c
@@ -259,10 +259,15 @@ static void FUNC2(alf_filter_luma, BIT_DEPTH, 
_sme2)(uint8_t *_dst,
                                                      const int vb_pos)
 {
     if ((width >= 16) && (height >= 16)) {
+        // If compiled without support for SME2 or SME-I16I64, we never assign
+        // the function pointer anyway, but make sure we don't produce a
+        // reference to the function which does not exist.
+#if HAVE_SME2 && HAVE_SME_I16I64
         int aligned_width = ALF_ALIGN_BY_4(width); // align width by 4
         uint64_t dims = ((uint64_t)height << 32u) | (uint64_t)aligned_width;
         uint64_t strides = ((uint64_t)src_stride << 32u) | 
(uint64_t)dst_stride;
         FUNC2(ff_vvc_alf_filter_luma, BIT_DEPTH, _sme2)(_dst, _src, strides, 
dims, filter, clip, vb_pos);
+#endif
     } else {
         FUNC2(alf_filter_luma, BIT_DEPTH, _neon)(_dst, dst_stride, _src, 
src_stride, width, height, filter, clip, vb_pos);
     }
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to