Index: llvm/lib/Target/ARM/ARMAsmPrinter.cpp =================================================================== --- llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -2124,10 +2124,9 @@ // Predicate. .addImm(ARMCC::AL) .addReg(0)); - EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tLDRi) + EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tMOVr) .addReg(ARM::R11) - .addReg(SrcReg) - .addImm(0) + .addReg(ARM::R7) // Predicate. .addImm(ARMCC::AL) .addReg(0)); Index: llvm/lib/Target/ARM/ARMInstrThumb.td =================================================================== --- llvm/lib/Target/ARM/ARMInstrThumb.td +++ llvm/lib/Target/ARM/ARMInstrThumb.td @@ -1545,7 +1545,7 @@ // FIXME: Non-IOS version(s) let isBarrier = 1, hasSideEffects = 1, isTerminator = 1, isCodeGenOnly = 1, - Defs = [ R7, LR, SP ] in + Defs = [ R7, R11, LR, SP ] in def tInt_eh_sjlj_longjmp : XI<(outs), (ins tGPR:$src, tGPR:$scratch), AddrModeNone, 0, IndexModeNone, Pseudo, NoItinerary, "", "", Index: llvm/test/CodeGen/ARM/setjmp_longjmp.ll =================================================================== --- llvm/test/CodeGen/ARM/setjmp_longjmp.ll +++ llvm/test/CodeGen/ARM/setjmp_longjmp.ll @@ -1,5 +1,6 @@ ; RUN: llc -simplifycfg-require-and-preserve-domtree=1 %s -o - | FileCheck %s ; RUN: llc -mtriple=armv7-linux -exception-model sjlj -simplifycfg-require-and-preserve-domtree=1 %s -o - | FileCheck %s -check-prefix CHECK-LINUX +; RUN: llc -mtriple=thumbv7-linux -exception-model sjlj -simplifycfg-require-and-preserve-domtree=1 %s -o - | FileCheck %s -check-prefix CHECK-LINUX-THUMB2 ; RUN: llc -mtriple=thumbv7-win32 -exception-model sjlj -simplifycfg-require-and-preserve-domtree=1 %s -o - | FileCheck %s -check-prefix CHECK-WIN32 target triple = "armv7-apple-ios" @@ -37,6 +38,13 @@ ; CHECK-LINUX-NEXT: ldr r11, {{\[}}[[BUFREG]]{{\]}} ; CHECK-LINUX-NEXT: bx [[DESTREG]] +; CHECK-LINUX-THUMB2: ldr [[DESTREG:r[0-9]+]], [{{\s*}}[[BUFREG:r[0-9]+]], #8] +; CHECK-LINUX-THUMB2-NEXT: mov sp, [[DESTREG]] +; CHECK-LINUX-THUMB2-NEXT: ldr [[DESTREG]], {{\[}}[[BUFREG]], #4] +; CHECK-LINUX-THUMB2-NEXT: ldr r7, {{\[}}[[BUFREG]]{{\]}} +; CHECK-LINUX-THUMB2-NEXT: mov r11, r7 +; CHECK-LINUX-THUMB2-NEXT: bx [[DESTREG]] + ; CHECK-WIN32: ldr.w r11, [{{\s*}}[[BUFREG:r[0-9]+]]] ; CHECK-WIN32-NEXT: ldr.w sp, {{\[}}[[BUFREG]], #8] ; CHECK-WIN32-NEXT: ldr.w pc, {{\[}}[[BUFREG]], #4]