[LLVMdev] Inline asm bug?

Eli Friedman eli.friedman at gmail.com
Tue Jan 8 14:24:12 PST 2013


On Tue, Jan 8, 2013 at 2:17 PM, Krzysztof Parzyszek
<kparzysz at codeaurora.org> wrote:
> On 1/8/2013 3:52 PM, Eli Friedman wrote:
>>
>>
>>  From gcc docs: "If your assembler instructions access memory in an
>> unpredictable fashion, add `memory' to the list of clobbered
>> registers. This causes GCC to not keep memory values cached in
>> registers across the assembler instruction and not optimize stores or
>> loads to that memory. You also should add the volatile keyword if the
>> memory affected is not listed in the inputs or outputs of the asm, as
>> the `memory' clobber does not count as a side-effect of the asm. "
>
>
> Yes, I've read this.  It's not a very precise description.  If I need to
> make the asm "volatile", then why would I need to put "memory" in the
> clobber list?  Shouldn't "asm volatile" be sufficient by itself?  If so,
> then what's the point of having the clobber "memory" in the first place?

It's kind of weird... inline asm hooks into the compiler at a low
level, so think of it this way: alias analysis queries the "memory"
clobber, but dead code elimination ignores the clobber list.  You're
right, this makes absolutely no sense from the user's perspective.

-Eli



More information about the llvm-dev mailing list