Since r346948, LLVM generates wrong MSP430 code for indirect input constraints inline assembly. For example, for the following IR snippet target triple = "msp430-unknown-unknown-elf" define void @f() { entry: call void asm sideeffect "mov r1, $0", "*m"(i8* inttoptr (i16 256 to i8*)) ret void } the inline assembly is wrongly translated into mov r1, 256(r2) instead of into mov r1, &256
The absolute addressing mode on msp430 is encoded exactly as the indexed one with r2 (status register) as a base. In other words, these two lines mov r1, 256(r2) and mov r1, &256 encode exactly the same instruction. There is no a correctness issue here. However, AsmPrinter could be taught to print absolute addressing mode in a canonical way.
Thanks for having a look at this. The assembler from TI's MSP430 GCC toolchain (MSP430-GCC 7.3.2.154 release) refuses to assemble mov r1, 256(r2) with the following error message Error: r2 should not be used in indexed addressing mode.
Created attachment 21336 [details] Proposed patch Convert r2-indexed addressing mode into absolute addressing mode
Fixed in r352178