Index: lib/Target/ARM/ARMAsmPrinter.cpp =================================================================== --- lib/Target/ARM/ARMAsmPrinter.cpp +++ lib/Target/ARM/ARMAsmPrinter.cpp @@ -1125,6 +1125,7 @@ Offset = 0; break; case ARM::ADDri: + case ARM::t2ADDri: Offset = -MI->getOperand(2).getImm(); break; case ARM::SUBri: Index: test/CodeGen/Thumb2/emit-unwinding.ll =================================================================== --- /dev/null +++ test/CodeGen/Thumb2/emit-unwinding.ll @@ -0,0 +1,22 @@ +; RUN: llc -mtriple thumbv7em-apple-unknown-eabi-macho %s -o - -O0 -disable-fp-elim | FileCheck %s + +; CHECK: add.w r11, sp, #{{[1-9]+}} + +define i32 @foo1(i32 %n) { +entry: + %n.addr = alloca i32, align 4 + %a1 = alloca [256 x i32], align 4 + store i32 %n, i32* %n.addr, align 4 + %arraydecay = getelementptr inbounds [256 x i32], [256 x i32]* %a1, i32 0, i32 0 + call void @foo2(i32* %arraydecay) + call void asm sideeffect "", "~{r4}"() #2 + %0 = load i32, i32* %n.addr, align 4 + %arrayidx = getelementptr inbounds [256 x i32], [256 x i32]* %a1, i32 0, i32 %0 + %1 = load i32, i32* %arrayidx, align 4 + %arrayidx1 = getelementptr inbounds [256 x i32], [256 x i32]* %a1, i32 0, i32 1 + %2 = load i32, i32* %arrayidx1, align 4 + %add = add nsw i32 %1, %2 + ret i32 %add +} + +declare void @foo2(i32*)