linux/arch/hexagon/include/asm
Kees Cook 799776f336 hexagon: Add __attribute_const__ to ffs()-family implementations
While tracking down a problem where constant expressions used by
BUILD_BUG_ON() suddenly stopped working[1], we found that an added static
initializer was convincing the compiler that it couldn't track the state
of the prior statically initialized value. Tracing this down found that
ffs() was used in the initializer macro, but since it wasn't marked with
__attribute__const__, the compiler had to assume the function might
change variable states as a side-effect (which is not true for ffs(),
which provides deterministic math results).

Add missing __attribute_const__ annotations to Hexagon's implementations
of fls(), ffs(), __ffs(), __fls(), and ffz() functions. These are
pure mathematical functions that always return the same result for
the same input with no side effects, making them eligible for compiler
optimization.

Build tested ARCH=hexagon defconfig with Clang 21.0.0git (LLVM=1).

Link: https://github.com/KSPP/linux/issues/364 [1]
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250804164417.1612371-8-kees@kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
2025-09-08 14:58:51 -07:00
..
Kbuild asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
asm-offsets.h
atomic.h locking/atomic: treewide: delete arch_atomic_*() kerneldoc 2023-06-05 09:57:24 +02:00
bitops.h hexagon: Add __attribute_const__ to ffs()-family implementations 2025-09-08 14:58:51 -07:00
cache.h
cacheflush.h mm: rationalise flush_icache_pages() and flush_icache_page() 2023-08-24 16:20:25 -07:00
checksum.h
cmpxchg.h hexagon: fix using plain integer as NULL pointer warning in cmpxchg 2025-01-30 18:44:54 -08:00
delay.h
dma.h
elf.h
exec.h
fixmap.h
fpu.h
futex.h
hexagon_vm.h
intrinsics.h
io.h hexagon: simplify asm/io.h for !HAS_IOPORT 2024-10-28 21:44:29 +00:00
irq.h hexagon: irq: add prototype for arch_do_IRQ() 2023-12-10 17:21:37 -08:00
irqflags.h
kgdb.h
linkage.h
mem-layout.h
mmu.h
mmu_context.h
page.h asm-generic updates for 6.13 2024-11-20 15:13:02 -08:00
perf_event.h
pgalloc.h mm: pgtable: convert some architectures to use tlb_remove_ptdesc() 2025-04-01 15:17:13 -07:00
pgtable.h mm: pgtable: fix pte_swp_exclusive 2025-06-11 14:52:08 -07:00
processor.h
ptrace.h hexagon: Remove unusable symbols from the ptrace.h uapi 2023-10-25 15:54:24 +02:00
setup.h hexagon: Move kernel prototypes out of uapi/asm/setup.h header 2025-01-30 18:45:45 -08:00
smp.h
spinlock.h
spinlock_types.h Improve consistency of '#error' directive messages 2024-11-11 17:17:04 -08:00
string.h
suspend.h
switch_to.h
syscall.h syscall.h: introduce syscall_set_nr() 2025-05-11 17:48:15 -07:00
syscalls.h hexagon: fix fadvise64_64 calling conventions 2024-06-25 15:57:37 +02:00
thread_info.h
time.h
timex.h
tlb.h
tlbflush.h
traps.h
uaccess.h
unistd.h hexagon: use new system call table 2024-07-10 14:23:38 +02:00
vdso.h
vermagic.h
vm_fault.h
vm_mmu.h
vmalloc.h