[cfe-dev] Some assembly fails in clang and succeeds in gcc

Reid Kleckner rnk at google.com
Wed Aug 6 13:05:30 PDT 2014


So, 1: is supposed to be a label?  I suspect that is not going to work.
 Consider:

$ cat t.cpp
int main() {
  asm ("1: jmp 1");
}

$ clang -cc1 t.cpp -S -o - | grep -A10 main:
_main:
        #APP
Ltmp0:
        jmp     1  # Not right...
        #NO_APP
        movl    $0, %eax
        retl

$ clang -cc1 t.cpp -emit-obj -o t.o
Assertion failed: Target.getSymA() && "Relocation must reference a
symbol!", file ..\lib\MC\WinCOFFObjectWriter.cpp, line 714

So, clearly we have bugs.  As a workaround, try using textual labels that
start with 'L' so they don't appear in the symbol table.


On Tue, Aug 5, 2014 at 6:01 PM, Yuri <yuri at rawbw.com> wrote:

> I am looking at one project that doesn't compile with clang++.
>
> Source in __asm__ __volatile__(...) after preprocessor looks like this:
> <...skipped...>"mov [r8+((1024+7-(15))-((1024+7-(15))/(8))*(8))*4]" ", "
> "ecx" ";"
>
>  "\n" "1" ":"
>  "add rsi" ", " "4*16" ";"
> <...skipped...>
>
>
> This place breaks with this message:
> sha.cpp:340:2: error: invalid instruction mnemonic 'prefix'
>         ASL(1)
>         ^
> ./cpu.h:224:17: note: expanded from macro 'ASL'
>         #define ASL(x) GNU_ASL(x)
>                        ^
> ./cpu.h:218:26: note: expanded from macro 'GNU_ASL'
>         #define GNU_ASL(x) "\n" #x ":"
>                                 ^
> <scratch space>:24:2: note: expanded from here
> "1"
>  ^
>
> However, there is the previous instance of the similar assembly that clang
> doesn't complain about:
>  "movdqa xmm1" ", " "[rcx+1*16]" ";"
>  "\n" "0" ":"
>  "movdqa [r8+((1024+7-(0+3))-((1024+7-(0+3))/(8))*(8))*4]" ", " "xmm1" ";"
>
> gcc compiles both places.
>
> What is wrong with the first place?
>
> Yuri
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140806/3b89b6f3/attachment.html>


More information about the cfe-dev mailing list