GCC assumes that input variables in inline assembly are fully consumed
before any output variable is written. This means it may allocate the
variables in the same register unless the output variables are marked
as early-clobber.
From Jeremy Huddleston:
I noticed a problem building pixman with clang and reported it to
the clang developers. They responded back with a comment about
the inline asm in pixman-mmx.c and suggested a fix:
"""
Incidentally, Jeremy, in the asm that reads
__asm__ (
"movq %7, %0\n"
"movq %7, %1\n"
"movq %7, %2\n"
"movq %7, %3\n"
"movq %7, %4\n"
"movq %7, %5\n"
"movq %7, %6\n"
: "=y" (v1), "=y" (v2), "=y" (v3),
"=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
: "y" (vfill));
all the output operands except the last one should be marked as
earlyclobber ("=&y"). This is working by accident with gcc.
"""
Cc: jeremyhu@apple.com
Reviewed-by: Matt Turner <mattst88@gmail.com>
"movq %7, %4\n"
"movq %7, %5\n"
"movq %7, %6\n"
- : "=y" (v1), "=y" (v2), "=y" (v3),
- "=y" (v4), "=y" (v5), "=y" (v6), "=y" (v7)
+ : "=&y" (v1), "=&y" (v2), "=&y" (v3),
+ "=&y" (v4), "=&y" (v5), "=&y" (v6), "=y" (v7)
: "y" (vfill));
#endif