From 01dbae1163b7da9a20912e1783e8b26af7bcb99f Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Wed, 10 Sep 2014 12:53:28 +0000 Subject: [PATCH] ARM: don't size-reduce STMs using the LR register. The only Thumb-1 multi-store capable of using LR is the PUSH instruction, which translates to STMDB, so we shouldn't convert STMIAs. Patch by Sergey Dmitrouk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217498 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/Thumb2SizeReduction.cpp | 2 +- test/CodeGen/ARM/wrong-t2stmia-size-opt.ll | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/ARM/wrong-t2stmia-size-opt.ll diff --git a/lib/Target/ARM/Thumb2SizeReduction.cpp b/lib/Target/ARM/Thumb2SizeReduction.cpp index 49a69fd3a6a..2176b839f1f 100644 --- a/lib/Target/ARM/Thumb2SizeReduction.cpp +++ b/lib/Target/ARM/Thumb2SizeReduction.cpp @@ -335,7 +335,7 @@ static bool VerifyLowRegs(MachineInstr *MI) { bool isPCOk = (Opc == ARM::t2LDMIA_RET || Opc == ARM::t2LDMIA || Opc == ARM::t2LDMDB || Opc == ARM::t2LDMIA_UPD || Opc == ARM::t2LDMDB_UPD); - bool isLROk = (Opc == ARM::t2STMIA_UPD || Opc == ARM::t2STMDB_UPD); + bool isLROk = (Opc == ARM::t2STMDB_UPD); bool isSPOk = isPCOk || isLROk; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); diff --git a/test/CodeGen/ARM/wrong-t2stmia-size-opt.ll b/test/CodeGen/ARM/wrong-t2stmia-size-opt.ll new file mode 100644 index 00000000000..7ecd2528310 --- /dev/null +++ b/test/CodeGen/ARM/wrong-t2stmia-size-opt.ll @@ -0,0 +1,20 @@ +; RUN: llc -mcpu=cortex-a9 -O1 -filetype=obj %s -o - | llvm-objdump -arch thumb -mcpu=cortex-a9 -d - | FileCheck %s + +target datalayout = "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "thumbv7--linux-gnueabi" + +declare i8* @llvm.returnaddress(i32) + +define i32* @wrong-t2stmia-size-reduction(i32* %addr, i32 %val0) minsize { + store i32 %val0, i32* %addr + %addr1 = getelementptr i32* %addr, i32 1 + %lr = call i8* @llvm.returnaddress(i32 0) + %lr32 = ptrtoint i8* %lr to i32 + store i32 %lr32, i32* %addr1 + %addr2 = getelementptr i32* %addr1, i32 1 + ret i32* %addr2 +} + +; Check that stm writes two registers. The bug caused one of registers (LR, +; which invalid for Thumb1 form of STMIA instruction) to be dropped. +; CHECK: stm{{[^,]*}}, {{{.*,.*}}} -- 2.34.1