[cfe-commits] [PATCH] Allow inline assembly to inherit readnone/readonly attributes from parent function

Chad Rosier mcrosier at apple.com
Wed May 2 14:39:52 PDT 2012

On May 2, 2012, at 2:23 PM, Eli Friedman wrote:

> On Wed, May 2, 2012 at 2:07 PM, Chad Rosier <mcrosier at apple.com> wrote:
>> The attached patch allows inline assembly to inherit the readnone/readonly function attribute from the caller.  This allows the attributes to be retained after function inlining.  In turn, CSE is able to do it's magic on inline assembly statements.
>> An orthogonal solution would be to add support for the const keyword for inline assembly (e.g., asm const("mov $0x12345678, %0" : "=r" (ptr)); ).
> It's not obvious to me that this is safe... __attribute((const)) means
> that a function doesn't cause expose any side-effects, not that it
> doesn't have any internal state.

Hence the reason I sent it to the list.

> Note that there's another way we can compute readnone for the given
> inline asm: an inline asm can be marked readnone if it doesn't have
> any memory operands, isn't volatile, and doesn't clobber memory.

This seems more reasonable as well as more robust.  I'll see if I can't take this approach unless someone can shoot holes in it.

 Thanks, Eli.


> -Eli

More information about the cfe-commits mailing list