[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] jump in inline assembly
From:       Reid Kleckner via cfe-dev <cfe-dev () lists ! llvm ! org>
Date:       2016-10-30 21:12:10
Message-ID: CACs=tyJSETghEELFY-ZTu_YnGUOmqpcMCwOM3uTiFp6zJ=nsEA () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Clang has no equivalent for GCC asm goto. LLVM does not support jumping
between inline asm blobs inside the same function.

Implementing that support is covered by
https://llvm.org/bugs/show_bug.cgi?id=9295, which is unlikely to happen.

On Fri, Oct 28, 2016 at 2:57 PM, Pietro Braione via cfe-dev <
cfe-dev@lists.llvm.org> wrote:

> I have a C program with an inline assembly instruction similar to this:
>
> a = b;
> if (foo)
>   asm volatile ("jmp *%0" : : "r" (baz)) /* baz points somewhere after etc
> */
>
> etc:
> /* here a is used */
>
> When compiled with -O2 clang moves the initialization of a after the if
> statement and before the first statement of etc, and as consequence the
> program segfaults when foo == 1.  It's clear that clang presumes that after
> the asm volatile instruction the execution will fall through the next
> statement. gcc allows to use the goto keyword after asm [volatile] to
> inform that an asm block may jump, but this seems not to work in clang.
> What is the clang equivalent of asm goto? My clang -v: Apple LLVM version
> 8.0.0 (clang-800.0.38).
>
> Best,
> Pietro Braione
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>

[Attachment #5 (text/html)]

<div dir="ltr">Clang has no equivalent for GCC asm goto. LLVM does not support \
jumping between inline asm blobs inside the same \
function.<div><br></div><div>Implementing that support is covered by <a \
href="https://llvm.org/bugs/show_bug.cgi?id=9295">https://llvm.org/bugs/show_bug.cgi?id=9295</a>, \
which is unlikely to happen.</div></div><div class="gmail_extra"><br><div \
class="gmail_quote">On Fri, Oct 28, 2016 at 2:57 PM, Pietro Braione via cfe-dev <span \
dir="ltr">&lt;<a href="mailto:cfe-dev@lists.llvm.org" \
target="_blank">cfe-dev@lists.llvm.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">I have a C program with an inline assembly instruction \
similar to this:<br> <br>
a = b;<br>
if (foo)<br>
   asm volatile ("jmp *%0" : : "r" (baz)) /* baz points somewhere after etc */<br>
<br>
etc:<br>
/* here a is used */<br>
<br>
When compiled with -O2 clang moves the initialization of a after the if statement and \
before the first statement of etc, and as consequence the program segfaults when foo \
== 1.   It's clear that clang presumes that after the asm volatile instruction the \
execution will fall through the next statement. gcc allows to use the goto keyword \
after asm [volatile] to inform that an asm block may jump, but this seems not to work \
in clang. What is the clang equivalent of asm goto? My clang -v: Apple LLVM version \
8.0.0 (clang-800.0.38).<br> <br>
Best,<br>
Pietro Braione<br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" \
target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br> \
</blockquote></div><br></div>


[Attachment #6 (text/plain)]

_______________________________________________
cfe-dev mailing list
cfe-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic