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

--- Comment #7 from peterz at infradead dot org ---
(In reply to peterz from comment #6)
> 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%2F2iZjXfCDJ@hirez.programming.kicks-ass.
> net/

Possible test case here:

  https://lore.kernel.org/all/yib0vyqmes9hr...@hirez.programming.kicks-ass.net/

Reply via email to