Newer versions of clang will allocate %rbx as one of the inline asm inputs,
even in PIC. This occurs when building ffmpeg with clang -fsanitize=address
-O1 -fPIE. Because the asm does clobber %bx whether PIC is on or off, just
include %bx in the clobber list regardless of whether PIC is on or off.

Patch attached, please review and apply on my behalf.

Nick

PS. While looking at this code, I have a couple more comments:
  a) What is supposed to be at -8(%rsp) that the asm saves and restores?
Doesn't this depend on whether the compiler is using %sp or %bp? A few of
us compiler engineers couldn't figure out what this is trying to do (save a
return value to %rax? but it returns void? or to save the return address of
the function? but it's never clobbered?)
  b) There's an inline comment suggesting that one variable in the inline
asm is "buf2". There is no "buf2" (did you mean "dst2" or "src2"?)
diff --git a/libswscale/x86/hscale_fast_bilinear_simd.c b/libswscale/x86/hscale_fast_bilinear_simd.c
index 103793d..bfb23e2 100644
--- a/libswscale/x86/hscale_fast_bilinear_simd.c
+++ b/libswscale/x86/hscale_fast_bilinear_simd.c
@@ -198,26 +198,15 @@ void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst,
     int16_t *filter    = c->hLumFilter;
     void    *mmxextFilterCode = c->lumMmxextFilterCode;
     int i;
-#if defined(PIC)
-    uint64_t ebxsave;
-#endif
 #if ARCH_X86_64
     uint64_t retsave;
 #endif
 
     __asm__ volatile(
-#if defined(PIC)
-        "mov               %%"REG_b", %5        \n\t"
-#if ARCH_X86_64
-        "mov               -8(%%rsp), %%"REG_a" \n\t"
-        "mov               %%"REG_a", %6        \n\t"
-#endif
-#else
 #if ARCH_X86_64
         "mov               -8(%%rsp), %%"REG_a" \n\t"
         "mov               %%"REG_a", %5        \n\t"
 #endif
-#endif
         "pxor                  %%mm7, %%mm7     \n\t"
         "mov                      %0, %%"REG_c" \n\t"
         "mov                      %1, %%"REG_D" \n\t"
@@ -256,30 +245,16 @@ void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst,
         CALL_MMXEXT_FILTER_CODE
         CALL_MMXEXT_FILTER_CODE
 
-#if defined(PIC)
-        "mov                      %5, %%"REG_b" \n\t"
-#if ARCH_X86_64
-        "mov                      %6, %%"REG_a" \n\t"
-        "mov               %%"REG_a", -8(%%rsp) \n\t"
-#endif
-#else
 #if ARCH_X86_64
         "mov                      %5, %%"REG_a" \n\t"
         "mov               %%"REG_a", -8(%%rsp) \n\t"
 #endif
-#endif
         :: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
            "m" (mmxextFilterCode)
-#if defined(PIC)
-          ,"m" (ebxsave)
-#endif
 #if ARCH_X86_64
           ,"m"(retsave)
 #endif
-        : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
-#if !defined(PIC)
-         ,"%"REG_b
-#endif
+        : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D ,"%"REG_b
     );
 
     for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--)
@@ -294,26 +269,15 @@ void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2,
     int16_t *filter    = c->hChrFilter;
     void    *mmxextFilterCode = c->chrMmxextFilterCode;
     int i;
-#if defined(PIC)
-    DECLARE_ALIGNED(8, uint64_t, ebxsave);
-#endif
 #if ARCH_X86_64
     DECLARE_ALIGNED(8, uint64_t, retsave);
 #endif
 
     __asm__ volatile(
-#if defined(PIC)
-        "mov          %%"REG_b", %7         \n\t"
-#if ARCH_X86_64
-        "mov          -8(%%rsp), %%"REG_a"  \n\t"
-        "mov          %%"REG_a", %8         \n\t"
-#endif
-#else
 #if ARCH_X86_64
         "mov          -8(%%rsp), %%"REG_a"  \n\t"
         "mov          %%"REG_a", %7         \n\t"
 #endif
-#endif
         "pxor             %%mm7, %%mm7      \n\t"
         "mov                 %0, %%"REG_c"  \n\t"
         "mov                 %1, %%"REG_D"  \n\t"
@@ -340,30 +304,16 @@ void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2,
         CALL_MMXEXT_FILTER_CODE
         CALL_MMXEXT_FILTER_CODE
 
-#if defined(PIC)
-        "mov %7, %%"REG_b"    \n\t"
-#if ARCH_X86_64
-        "mov                 %8, %%"REG_a"  \n\t"
-        "mov          %%"REG_a", -8(%%rsp)  \n\t"
-#endif
-#else
 #if ARCH_X86_64
         "mov                 %7, %%"REG_a"  \n\t"
         "mov          %%"REG_a", -8(%%rsp)  \n\t"
 #endif
-#endif
         :: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos),
            "m" (mmxextFilterCode), "m" (src2), "m"(dst2)
-#if defined(PIC)
-          ,"m" (ebxsave)
-#endif
 #if ARCH_X86_64
           ,"m"(retsave)
 #endif
-        : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
-#if !defined(PIC)
-         ,"%"REG_b
-#endif
+        : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D ,"%"REG_b
     );
 
     for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to