Building nf_synproxy_core.c for i386 with LLVM/Clang fails with
"inline assembly requires more registers than available". The
csum_ipv6_magic() inline asm demands five registers at once: an
early-clobber output for sum plus four "r" inputs (saddr, daddr,
htonl(len), htonl(proto)). i386 only has six GPRs, so under register
pressure at inlined call sites Clang cannot satisfy the constraints.
Relax the register-only "r" constraints on the len and proto operands
to "g" (register, memory, or immediate). Since the asm uses adcl,
which accepts memory and immediate sources for these operands, the
generated checksum is unchanged; the compiler can now fold the constants
to immediates/memory and only three hard registers are needed.
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
arch/x86/include/asm/checksum_32.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
index 17da95387997..f74873a5e351 100644
--- a/arch/x86/include/asm/checksum_32.h
+++ b/arch/x86/include/asm/checksum_32.h
@@ -159,7 +159,7 @@ static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
"adcl $0, %0 ;\n"
: "=&r" (sum)
: "r" (saddr), "r" (daddr),
- "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
+ "g" (htonl(len)), "g" (htonl(proto)), "0" (sum)
: "memory");
return csum_fold(sum);
--
2.55.0