Index: lib/Target/ARM/ARMBaseInstrInfo.cpp =================================================================== --- lib/Target/ARM/ARMBaseInstrInfo.cpp +++ lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -2331,6 +2331,8 @@ for (int CurRegEnc = FirstRegEnc - 1; CurRegEnc >= 0 && RegsNeeded; --CurRegEnc) { unsigned CurReg = RegClass->getRegister(CurRegEnc); + if (IsT1PushPop && CurReg > ARM::R7) + continue; if (!IsPop) { // Pushing any register is completely harmless, mark the register involved // as undef since we don't care about its value and must not restore it Index: test/CodeGen/ARM/fold-stack-adjust.ll =================================================================== --- test/CodeGen/ARM/fold-stack-adjust.ll +++ test/CodeGen/ARM/fold-stack-adjust.ll @@ -2,6 +2,7 @@ ; exerce the path for PR18136. ; RUN: llc -mtriple=thumbv7-apple-none-macho < %s -enable-shrink-wrap=false | FileCheck %s ; RUN: llc -mtriple=thumbv6m-apple-none-macho -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-T1 +; RUN: llc -mtriple=thumbv6m-apple-none-macho < %s | FileCheck %s --check-prefix=CHECK-T1-NOFP ; RUN: llc -mtriple=thumbv7-apple-darwin-ios -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-IOS ; RUN: llc -mtriple=thumbv7--linux-gnueabi -frame-pointer=all < %s | FileCheck %s --check-prefix=CHECK-LINUX @@ -232,4 +233,13 @@ ret void } +define void @test_long_fn() minsize nounwind optsize { +; CHECK-T1-NOFP-LABEL: test_long_fn: +; CHECK-T1-NOFP: push {r7, lr} +entry: + %z = alloca i32, align 4 + call void asm sideeffect ".space 3000", "r"(i32* nonnull %z) + ret void +} + declare void @llvm.va_start(i8*) nounwind