Skip to contentSkip to conversation

lib/crc32.c: mark crc32_le_base/__crc32c_le_base aliases as __pure

PATCH In review Miguel Ojeda 3 participants 3 messages Jan 24, 2019 – Jan 25, 2019 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/crc32.c: mark crc32_le_base/__crc32c_le_base aliases as __pure

The upcoming GCC 9 release extends the -Wmissing-attributes warnings (enabled by -Wall) to C and aliases: it warns when particular function attributes are missing in the aliases but not in their target.

In particular, it triggers here because crc32_le_base/__crc32c_le_base aren't __pure while their target crc32_le/__crc32c_le are.

These aliases are used by architectures as a fallback in accelerated versions of CRC32. See commit 9784d82db3eb ("lib/crc32: make core crc32() routines weak so they can be overridden").

Therefore, being fallbacks, it is likely that even if the aliases were called from C, there wouldn't be any optimizations possible. Currently, the only user is arm64, which calls this from asm.

Still, marking the aliases as __pure makes sense and is a good idea for documentation purposes and possible future optimizations, which also silences the warning.

---
I am picking this up through the compiler-attributes tree and putting it into -next along with the other cleanup for -Wmissing-attributes (unless some other maintainer wants it).

 lib/crc32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/crc32.c +2 -2
index 45b1d67a1767..4a20455d1f61 100644
@@ -206,8 +206,8 @@ u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len)
 EXPORT_SYMBOL(crc32_le);
 EXPORT_SYMBOL(__crc32c_le);
 
-u32 crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
-u32 __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
+u32 __pure crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
+u32 __pure __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
 
 /*
  * This multiplies the polynomials x and y modulo the given modulus.
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Miguel Ojeda

The upcoming GCC 9 release extends the -Wmissing-attributes warnings (enabled by -Wall) to C and aliases: it warns when particular function attributes are missing in the aliases but not in their target.

In particular, it triggers here because crc32_le_base/__crc32c_le_base aren't __pure while their target crc32_le/__crc32c_le are.

These aliases are used by architectures as a fallback in accelerated versions of CRC32. See commit 9784d82db3eb ("lib/crc32: make core crc32() routines weak so they can be overridden").

Therefore, being fallbacks, it is likely that even if the aliases were called from C, there wouldn't be any optimizations possible. Currently, the only user is arm64, which calls this from asm.

Quoted 5 lines

Still, marking the aliases as __pure makes sense and is a good idea for documentation purposes and possible future optimizations, which also silences the warning.

Quoted 26 lines

---
I am picking this up through the compiler-attributes tree and putting it into -next along with the other cleanup for -Wmissing-attributes (unless some other maintainer wants it).

 lib/crc32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/crc32.c +2 -3
index 45b1d67a1767..4a20455d1f61 100644
@@ -206,8 +206,8 @@ u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len)
 EXPORT_SYMBOL(crc32_le);
 EXPORT_SYMBOL(__crc32c_le);
 
-u32 crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
-u32 __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
+u32 __pure crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
+u32 __pure __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
 
 /*
  * This multiplies the polynomials x and y modulo the given modulus.
--

2.17.1

Tested-by on v1 1/1
#2 lore raw
In reply to Miguel Ojeda
Quoted 34 lines · Miguel Ojeda

The upcoming GCC 9 release extends the -Wmissing-attributes warnings (enabled by -Wall) to C and aliases: it warns when particular function attributes are missing in the aliases but not in their target.

In particular, it triggers here because crc32_le_base/__crc32c_le_base aren't __pure while their target crc32_le/__crc32c_le are.

These aliases are used by architectures as a fallback in accelerated versions of CRC32. See commit 9784d82db3eb ("lib/crc32: make core crc32() routines weak so they can be overridden").

Therefore, being fallbacks, it is likely that even if the aliases were called from C, there wouldn't be any optimizations possible. Currently, the only user is arm64, which calls this from asm.

Still, marking the aliases as __pure makes sense and is a good idea for documentation purposes and possible future optimizations, which also silences the warning.

---
I am picking this up through the compiler-attributes tree and putting it into -next along with the other cleanup for -Wmissing-attributes (unless some other maintainer wants it).

  lib/crc32.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/crc32.c +0 -0
index 45b1d67a1767..4a20455d1f61 100644

lib/crc32.c u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len) · line 213

Quoted 10 lines
lib/crc32.c +2 -2
@@ -206,8 +206,8 @@ u32 __pure __weak __crc32c_le(u32 crc, unsigned char const *p, size_t len)
  EXPORT_SYMBOL(crc32_le);
  EXPORT_SYMBOL(__crc32c_le);
 
-u32 crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
-u32 __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
+u32 __pure crc32_le_base(u32, unsigned char const *, size_t) __alias(crc32_le);
+u32 __pure __crc32c_le_base(u32, unsigned char const *, size_t) __alias(__crc32c_le);
 
  /*
   * This multiplies the polynomials x and y modulo the given modulus.