[llvm] r199818 - Fix inline assembly that switches between ARM and Thumb modes

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Jan 24 06:54:37 PST 2014


> The problem we need to solve is code like this:
>
>   int foo(int a, int b) {
>     int r = a + b;
>     asm volatile(
>         ".align 2     \n"
>         ".arm         \n"
>         "add r0,r0,r0 \n"
>     : : "r"(r));
>     return r+1;
>   }
>
> If we compile this function in thumb mode then the inline assembly
> will switch to arm mode. We need to make sure that we switch back to
> thumb mode after emitting the inline assembly or we will incorrectly
> encode the instructions that follow (i.e. the assembly instructions
> for return r+1).

Is this supported by GCC too? If not, should we document it as an extension?

Why is this needed at the MCStreamer level? Why can't codegen use
EmitAssemblerFlag directly?

Cheers,
Rafael



More information about the llvm-commits mailing list