From d912ffaba541f6869165b28df1077f3d24e079a1 Mon Sep 17 00:00:00 2001 From: Amara Emerson Date: Tue, 3 Jul 2018 15:59:26 +0000 Subject: [PATCH] [AArch64][GlobalISel] Fix fallbacks introduced in r336120 due to unselectable stores. r336120 resulted in falling back to SelectionDAG more often due to the G_STORE MMOs not matching the vreg size. This fixes that by explicitly any-extending the value. llvm-svn: 336209 --- llvm/lib/Target/AArch64/AArch64CallLowering.cpp | 7 +++++-- .../CodeGen/AArch64/GlobalISel/arm64-callingconv-ios.ll | 9 ++++++--- .../AArch64/GlobalISel/irtranslator-exceptions.ll | 3 ++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp index b8644ba1432d..26d532555e78 100644 --- a/llvm/lib/Target/AArch64/AArch64CallLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64CallLowering.cpp @@ -155,9 +155,12 @@ struct OutgoingArgHandler : public CallLowering::ValueHandler { void assignValueToAddress(unsigned ValVReg, unsigned Addr, uint64_t Size, MachinePointerInfo &MPO, CCValAssign &VA) override { - if (VA.getLocInfo() == CCValAssign::LocInfo::AExt) + if (VA.getLocInfo() == CCValAssign::LocInfo::AExt) { Size = VA.getLocVT().getSizeInBits() / 8; - + ValVReg = MIRBuilder.buildAnyExt(LLT::scalar(Size * 8), ValVReg) + ->getOperand(0) + .getReg(); + } auto MMO = MIRBuilder.getMF().getMachineMemOperand( MPO, MachineMemOperand::MOStore, Size, 0); MIRBuilder.buildStore(ValVReg, Addr, *MMO); diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-callingconv-ios.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-callingconv-ios.ll index 9e4015a5827c..256bcf28e66c 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-callingconv-ios.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-callingconv-ios.ll @@ -16,9 +16,12 @@ target triple = "aarch64-apple-ios9.0" ; CHECK: $w0 = COPY [[ANSWER]] ; CHECK: $d0 = COPY [[D_ONE]] ; CHECK: $x1 = COPY [[TWELVE]] -; CHECK: G_STORE [[THREE]](s8), {{%[0-9]+}}(p0) :: (store 8 into stack, align 0) -; CHECK: G_STORE [[ONE]](s16), {{%[0-9]+}}(p0) :: (store 8 into stack + 8, align 0) -; CHECK: G_STORE [[FOUR]](s32), {{%[0-9]+}}(p0) :: (store 8 into stack + 16, align 0) +; CHECK: [[THREE_EXT:%[0-9]+]]:_(s64) = G_ANYEXT [[THREE]] +; CHECK: G_STORE [[THREE_EXT]](s64), {{%[0-9]+}}(p0) :: (store 8 into stack, align 0) +; CHECK: [[ONE_EXT:%[0-9]+]]:_(s64) = G_ANYEXT [[ONE]] +; CHECK: G_STORE [[ONE_EXT]](s64), {{%[0-9]+}}(p0) :: (store 8 into stack + 8, align 0) +; CHECK: [[FOUR_EXT:%[0-9]+]]:_(s64) = G_ANYEXT [[FOUR]] +; CHECK: G_STORE [[FOUR_EXT]](s64), {{%[0-9]+}}(p0) :: (store 8 into stack + 16, align 0) ; CHECK: G_STORE [[F_ONE]](s32), {{%[0-9]+}}(p0) :: (store 4 into stack + 24, align 0) ; CHECK: G_STORE [[TWO]](s64), {{%[0-9]+}}(p0) :: (store 8 into stack + 32, align 0) declare void @varargs(i32, double, i64, ...) diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll index 855d3bcd4c4e..6b8827f095d4 100644 --- a/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-exceptions.ll @@ -74,7 +74,8 @@ continue: ; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_CONSTANT i64 0 ; CHECK: [[SLOT:%[0-9]+]]:_(p0) = G_GEP [[SP]], [[OFFSET]](s64) -; CHECK: G_STORE [[ANSWER]](s32), [[SLOT]] +; CHECK: [[ANSWER_EXT:%[0-9]+]]:_(s64) = G_ANYEXT [[ANSWER]] +; CHECK: G_STORE [[ANSWER_EXT]](s64), [[SLOT]] ; CHECK: [[SP:%[0-9]+]]:_(p0) = COPY $sp ; CHECK: [[OFFSET:%[0-9]+]]:_(s64) = G_CONSTANT i64 8