https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105160

peterz at infradead dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peterz at infradead dot org

--- Comment #6 from peterz at infradead dot org ---
Happy accident; I've been wanting to allow doing something like:

static __always_inline __pure bool arch_static_branch(struct static_key * const
key)
{
    asm_volatile_goto("1:"
                      ".byte " __stringify(BYTES_NOP5) "\n\t"
                      ".pushsection __jump_table, \"aw\" \n\t"
                      _ASM_ALIGN "\n\t"
                      ".long 1b - ., %l[l_yes] - . \n\t"
                      _ASM_PTR "%c0 - . \n\t"
                      ".popsecion \n\t"
                      : : "i" (key) : : l_yes);
    return false;
l_yes:
    return true;
}


Now, since asm-goto is implicitly volatile, and asm volatile (per this thread)
destroys __pure due to side-effects, this doesn't actually work. But I'd like
to still have the explicit pure attribute override this. If the programmer gets
it wrong like this, he/she gets to keep the pieces.

Specifically in this case, he result of the function really only depends on the
@key argument. Any call to this will have the exact same outcome and merging
multiple instances is *good*.

Also see this thread on linux-toolchains:

 
https://lore.kernel.org/all/yg80wg%2f2izjxf...@hirez.programming.kicks-ass.net/

Reply via email to