Moshe Kravchik
2012-Jul-11 08:44 UTC
[LLVMdev] A problem with inline assembly in llvmc for ARM
Hi, I encountered an issue with inline assembly in my c files compiled with llvmc. When I have a push instruction in the inline assembly like: __asm__ volatile ( "push {r4}\n\t" ); the compiler will drop the curly braces and leave it in the generated assembly file as: push r4 And this is non-conformant with the ARM assembly syntax for push and pop. Is there any ways to resolve or overcome that? I need to keep the assembly inline, and not move it to the .s files. I used the following llvmc: llvm version 2.9 Optimized build. Built Sep 8 2011 (11:43:28). Host: i386-pc-linux-gnu Host CPU: core2 Using the following flags:-Wllc,="-mtriple=arm-linux-eabi" -fmessage-length=0 -std=c99 -Wno-trigraphs -O3 -fpic -Wreturn-type -Wunused-variable -fvisibility=hidden -D__ARM_EABI__ -DANDROID -isysroot/usr/local/android/android-ndk-r6b/platforms/android-8/arch-arm Thanks a lot,Moshe -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120711/848cddcc/attachment.html>
Jim Grosbach
2012-Jul-11 16:12 UTC
[LLVMdev] A problem with inline assembly in llvmc for ARM
Looks like a problem with llvmc. Your example works fine with clang. ~/tmp $ cat foo.c void foo() { __asm__ volatile ("push {r4}\n\t"); } gilgamesh: ~/tmp $ clang -target arm-linux-eabi -S -Os foo.c -o - .syntax unified .eabi_attribute 20, 1 .eabi_attribute 21, 1 .eabi_attribute 23, 3 .eabi_attribute 24, 1 .eabi_attribute 25, 1 .file "foo.c" .text .globl foo .align 2 .type foo,%function foo: @APP push {r4} @NO_APP bx lr .Ltmp0: .size foo, .Ltmp0-foo On Jul 11, 2012, at 1:44 AM, Moshe Kravchik wrote:> Hi, > > I encountered an issue with inline assembly in my c files compiled with llvmc. > > When I have a push instruction in the inline assembly like: > > __asm__ volatile ( > "push {r4}\n\t" > ); > > the compiler will drop the curly braces and leave it in the generated assembly file as: > push r4 > > And this is non-conformant with the ARM assembly synta! x for push and pop. > > Is there any ways to resolve or overcome that? I need to keep the assembly inline, and not move it to the .s files. > > I used the following llvmc: > llvm version 2.9 > Optimized build. > Built Sep 8 2011 (11:43:28). > Host: i386-pc-linux-gnu > Host CPU: core2 > > Using the following flags: > -Wllc,="-mtriple=arm-linux-eabi" -fmessage-length=0 -std=c99 -Wno-trigraphs -O3 -fpic -Wreturn-type -Wunused-variable -fvisibility=hidden -D__ARM_EABI__ -DANDROID -isysroot/usr/local/android/android-ndk-r6b/platforms/android-8/arch-arm > > Thanks a lot, > Moshe > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120711/0a9e5de8/attachment.html>
Anton Korobeynikov
2012-Jul-11 17:45 UTC
[LLVMdev] A problem with inline assembly in llvmc for ARM
> Looks like a problem with llvmc. Your example works fine with clang.llvmc does not do the actual compilation, it executed llvm-gcc / llc. So, it seems problem is there. Anyway, LLVM 2.9 is too ancient, especially for ARM. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Hi, I'm looking for a pragma to insert in my source that will turn the optimization off for that file. Could not find one, it is possible? Thanks a lot,Moshe -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120726/e713a744/attachment.html>
On Thu, Jul 26, 2012 at 12:48 AM, Moshe Kravchik <mkravchik at hotmail.com> wrote:> > Hi, > > I'm looking for a pragma to insert in my source that will turn the > optimization off for that file. Could not find one, it is possible? > > Thanks a lot, > MosheNo, clang does not have a pragma for this. You should use your build system to pass -O0 to clang for this file. Also, why do you need to disable optimization? - Michael Spencer