From 7f4f923aa57ad8d7ed3f84c532b583f590a68a49 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Mon, 11 Aug 2014 21:39:53 +0000 Subject: [PATCH] [AArch64] Fix registerAllocator assigns same register for base and wback in pre/post-index load and store. Patch by Steven Wu git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215390 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/AArch64InstrFormats.td | 13 ++++++------- test/CodeGen/AArch64/arm64-indexed-memory.ll | 12 ++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/Target/AArch64/AArch64InstrFormats.td b/lib/Target/AArch64/AArch64InstrFormats.td index 3f764239290..6a1bab52ab8 100644 --- a/lib/Target/AArch64/AArch64InstrFormats.td +++ b/lib/Target/AArch64/AArch64InstrFormats.td @@ -2998,7 +2998,7 @@ class LoadPreIdx sz, bit V, bits<2> opc, RegisterClass regtype, : BaseLoadStorePreIdx, + "$Rn = $wback,@earlyclobber $wback", []>, Sched<[WriteLD, WriteAdr]>; let mayStore = 1, mayLoad = 0 in @@ -3007,7 +3007,7 @@ class StorePreIdx sz, bit V, bits<2> opc, RegisterClass regtype, : BaseLoadStorePreIdx, Sched<[WriteAdr, WriteST]>; @@ -3017,7 +3017,6 @@ class StorePreIdx sz, bit V, bits<2> opc, RegisterClass regtype, // Load/store post-indexed //--- -// (pre-index) load/stores. class BaseLoadStorePostIdx sz, bit V, bits<2> opc, dag oops, dag iops, string asm, string cstr, list pat> : I { @@ -3045,7 +3044,7 @@ class LoadPostIdx sz, bit V, bits<2> opc, RegisterClass regtype, : BaseLoadStorePostIdx, + asm, "$Rn = $wback,@earlyclobber $wback", []>, Sched<[WriteLD, WriteI]>; let mayStore = 1, mayLoad = 0 in @@ -3054,7 +3053,7 @@ class StorePostIdx sz, bit V, bits<2> opc, RegisterClass regtype, : BaseLoadStorePostIdx, Sched<[WriteAdr, WriteST, ReadAdrBase]>; @@ -3118,7 +3117,7 @@ multiclass StorePairOffset opc, bit V, RegisterClass regtype, // (pre-indexed) class BaseLoadStorePairPreIdx opc, bit V, bit L, dag oops, dag iops, string asm> - : I { + : I { bits<5> Rt; bits<5> Rt2; bits<5> Rn; @@ -3159,7 +3158,7 @@ class StorePairPreIdx opc, bit V, RegisterClass regtype, class BaseLoadStorePairPostIdx opc, bit V, bit L, dag oops, dag iops, string asm> - : I { + : I { bits<5> Rt; bits<5> Rt2; bits<5> Rn; diff --git a/test/CodeGen/AArch64/arm64-indexed-memory.ll b/test/CodeGen/AArch64/arm64-indexed-memory.ll index e501c6e403b..a8620f428da 100644 --- a/test/CodeGen/AArch64/arm64-indexed-memory.ll +++ b/test/CodeGen/AArch64/arm64-indexed-memory.ll @@ -349,3 +349,15 @@ define i8* @preidx8sext64(i8* %src, i64* %out) { store i64 %ext, i64* %out, align 4 ret i8* %ptr } + +; This test checks if illegal post-index is generated + +define i64* @postidx_clobber(i64* %addr) nounwind noinline ssp { +; CHECK-LABEL: postidx_clobber: +; CHECK-NOT: str x0, [x0], #8 +; ret + %paddr = bitcast i64* %addr to i64** + store i64* %addr, i64** %paddr + %newaddr = getelementptr i64* %addr, i32 1 + ret i64* %newaddr +} -- 2.34.1