[cfe-dev] SOLVED: asm directive: symbolic label syntax
Alexander von Below via cfe-dev
cfe-dev at lists.llvm.org
Mon Oct 11 00:32:58 PDT 2021
Thanks for everyone on this list!
The big difference between my native assembly code and the inline code is, that the cfe generates the directive: ‘.subsections_via_symbols’ , and I will have to do some searching to understand precisely what this does …
But because of this, indeed, labels must be prefixed with „L“. Like
b.lt Lcont
sub w5, w5, #32
Lcont:
strb w5, [x9], #1
It also keeps my curios why the gcc frontend seems to behave differently here
> Am 11.10.2021 um 01:59 schrieb Brian Cain <brian.cain at gmail.com>:
>
> Does the behavior change if you declare "cont" as a global symbol? Does the symbol have to be "cont"? Would ".Lcont" suffice? Many targets treat leading ".L" as implicitly local symbols.
>
> On Sun, Oct 10, 2021 at 6:30 PM Alexander von Below via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> Thanks a lot for your answer, and yes, I do:
>
> Working code (using numeric label): https://github.com/below/HelloSilicon/blob/main/Chapter%2009/uppertst4.c
> Non-working (original) code: https://github.com/below/HelloSilicon/blob/4c4b2911c43644adfd3b78aee093857444f28472/Chapter%209/uppertst4.c
>
> Compile using the makefile in the same folder, or using "clang -o uppertst4 uppertst4.c“
>
> On godbolt, running the original code through armv8-a-clang 11.0.1 or trunk, everything seems to work fine. There is an unrelated warning, but no errors. The output shows both the loop and the cont labels: https://godbolt.org/z/xY5afcYdW
>
> Compiling the code with the symbolic cont label on an M1 using clang-1300.0.29.3 produces the errors:
>
> uppertst4.c:22:4: error: conditional branch requires assembler-local label. 'cont' is external.
> "BGT cont\n"
> ^
> <inline asm>:4:1: note: instantiated into assembly here
> BGT cont
> ^
> uppertst4.c:24:4: error: conditional branch requires assembler-local label. 'cont' is external.
> "BLT cont\n"
> ^
> <inline asm>:6:1: note: instantiated into assembly here
> BLT cont
> ^
> uppertst4.c:28:4: error: conditional branch requires assembler-local label. 'loop' is external.
> "B.NE loop\n"
> ^
> <inline asm>:10:1: note: instantiated into assembly here
> B.NE loop
> ^
>
> Notably, now for both loop and cont, while it is sufficient to replace cont with a numeric label.
>
> I would be glad to find out if I am doing it wrong, or if this is an issue in clang. And now my curiosity is raised why godbolt appears to differ from clang on macOS …
>
> Thanks again
>
> Alex
>
>
> > Am 11.10.2021 um 00:26 schrieb Joerg Sonnenberger via cfe-dev <cfe-dev at lists.llvm.org>:
> >
> > On Sun, Oct 10, 2021 at 12:27:28PM +0200, Alexander von Below via cfe-dev wrote:
> >> I have tried to adapt gnu as code for Apple Silicon, and I have found
> >> explanations for most differences. There is one issue I still have:
> >
> > Do you actually have a complete self-contained example? Try godbolt.org.
> >
> > Joerg
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
> --
> -Brian
More information about the cfe-dev
mailing list