On May 2, 2012, at 2:44 PM, Eric Christopher wrote:

> 
> On May 2, 2012, at 2:41 PM, Chad Rosier <[email protected]> wrote:
> 
>> 
>> On May 2, 2012, at 2:29 PM, Eric Christopher wrote:
>> 
>>> 
>>> On May 2, 2012, at 2:23 PM, Eli Friedman <[email protected]> wrote:
>>> 
>>>> On Wed, May 2, 2012 at 2:07 PM, Chad Rosier <[email protected]> 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.
>>>> 
>>> 
>>> Perhaps a way to give a statement an attribute then?
>> 
>> I think this is what I proposed as the orthogonal approach.  However, 
>> assuming what Eli suggest below is correct, then this is not necessary.  We 
>> can detect constness.
>> 
>>> 
>>> In this case it's a read from memory so it'd be readonly... but the point 
>>> is good.
> 
> *nod* but at that point you're parsing the inline asm to look around and see 
> if it does anything you don't want - I worry about people lying (or making a 
> mistake) and not marking something as clobber that is, etc.

I suspect this is by and large the reason clang hasn't been overly aggressive 
in optimizing inline assembly; misuse and mistakes.  :o/

> 
> That said, it's probably no worse than any other solution :)
> 
> -eric

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to