From 7cd0201f029101c7b736e027f8c5e590d4350da4 Mon Sep 17 00:00:00 2001 From: Tilmann Scheller Date: Fri, 18 Jul 2014 12:05:49 +0000 Subject: [PATCH] [ARM] Add earlyclobber constraint to pre/post-indexed ARM STR instructions. The post-indexed instructions were missing the constraint, causing unpredictable STR instructions to be emitted. The earlyclobber constraint on the pre-indexed STR instructions is not strictly necessary, as the instruction selection for pre-indexed STR instructions goes through an additional layer of pseudo instructions which have the constraint defined, however it doesn't hurt to specify the constraint directly on the pre-indexed instructions as well, since at some point someone might create instances of them programmatically and then the constraint is definitely needed. This fixes PR20323. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213369 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMInstrInfo.td | 10 ++++++---- .../CodeGen/ARM/2014-07-18-earlyclobber-str-post.ll | 13 +++++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 test/CodeGen/ARM/2014-07-18-earlyclobber-str-post.ll diff --git a/lib/Target/ARM/ARMInstrInfo.td b/lib/Target/ARM/ARMInstrInfo.td index 2bb89765955..f0e145a394b 100644 --- a/lib/Target/ARM/ARMInstrInfo.td +++ b/lib/Target/ARM/ARMInstrInfo.td @@ -2708,7 +2708,8 @@ multiclass AI2_stridx { + opc, "\t$Rt, $addr!", + "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { bits<17> addr; let Inst{25} = 0; let Inst{23} = addr{12}; // U (add = ('U' == 1)) @@ -2720,7 +2721,8 @@ multiclass AI2_stridx { + opc, "\t$Rt, $addr!", + "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { bits<17> addr; let Inst{25} = 1; let Inst{23} = addr{12}; // U (add = ('U' == 1)) @@ -2733,7 +2735,7 @@ multiclass AI2_stridx { + "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { // {12} isAdd // {11-0} imm12/Rm bits<14> offset; @@ -2751,7 +2753,7 @@ multiclass AI2_stridx { + "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> { // {12} isAdd // {11-0} imm12/Rm bits<14> offset; diff --git a/test/CodeGen/ARM/2014-07-18-earlyclobber-str-post.ll b/test/CodeGen/ARM/2014-07-18-earlyclobber-str-post.ll new file mode 100644 index 00000000000..9ea762ae9bf --- /dev/null +++ b/test/CodeGen/ARM/2014-07-18-earlyclobber-str-post.ll @@ -0,0 +1,13 @@ +; RUN: llc -mtriple=armv7-linux-gnueabihf %s -o - | FileCheck %s + +; Check that we don't create an unpredictable STR instruction, +; e.g. str r0, [r0], #4 + +define i32* @earlyclobber-str-post(i32* %addr) nounwind { +; CHECK: earlyclobber-str-post +; CHECK-NOT: str r[[REG:[0-9]+]], [r[[REG]]], #4 + %val = ptrtoint i32* %addr to i32 + store i32 %val, i32* %addr + %new = getelementptr i32* %addr, i32 1 + ret i32* %new +} -- 2.34.1