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 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

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

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.

Thanks for your reply, so what do you suggest?
Do you know if there is a version that fixes this?

Moshe

Thanks for your reply, so what do you suggest?
Do you know if there is a version that fixes this?

Yes, since LLVM 2.9 two version of LLVM were released - 3.0 and 3.1.

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

No, 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

Thank you. The reason I want to turn them off is that the generated code looks wrong to me and I suspect it is due to optimization.