[llvm-commits] [PATCH] x86: Always emit displacements when parentheses are present

Kaelyn Uhrain rikka at google.com
Fri Sep 30 09:43:06 PDT 2011


On Fri, Sep 30, 2011 at 12:41 AM, Nick Lewycky <nicholas at mxc.ca> wrote:

> Kaelyn Uhrain wrote:
>
>> Hi,
>>
>> In X86AsmPrinter::**printLeaMemReference, immediate displacements for
>> memory references currently are not being emitted if the memory
>> reference has parentheses and the displacement is zero. This breaks
>> inline assembly code that adds a constant to the displacement, e.g.:
>> "leal 128+%0, %%edx" where %0 is a memory reference. Currently the
>> emitted code would look like "leal 128+(%esp)" which triggers a warning
>> (that an operand is missing and zero is being assumed) with GNU as and
>> is not accepted at all by llvm-mc. With this patch "leal 128+0(%esp)" is
>> emitted, which is happily accepted by both gas and llvm-mc.
>>
>
> Thanks for writing this! :)
>
> +; Make sure we generate acceptable memory references for things like (in
> C):
> +;    void test8(char *tmp) {
> +;        __asm__ volatile(
> +;    " leal 128+%0,%%edx\n\t"
> +;      :
> +;      :"m"(tmp)
> +;      :"memory","%edx");
> +;    }
> +; CHECK: leal 128+0(%esp),%edx
> +define void @test8(i8* %tmp) nounwind {
>
> Also add "+; CHECK: test8" first, to make it clear that we can't match any
> leal earlier in the file.
>

Will do! Thanks. :)

 - Kaelyn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110930/26b1f1e3/attachment.html>


More information about the llvm-commits mailing list