summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-08-17 02:42:24 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-08-17 02:42:24 +0000
commitdd8c16b58e44807b1adade487df5843a6db7baa2 (patch)
treee14aefe4e57fbf853b41f8437641d949d127d021
parent2f9743d2eaafdf7a4e56bd833e029a54354168e9 (diff)
downloadbcm5719-llvm-dd8c16b58e44807b1adade487df5843a6db7baa2.tar.gz
bcm5719-llvm-dd8c16b58e44807b1adade487df5843a6db7baa2.zip
ARM: mark CPSR as clobbered for Windows VLAs
When lowering a VLA, we emit a __chstk call. However, this call can internally clobber CPSR. We did not mark this register as an ImpDef, which could potentially allow a comparison to be hoisted above the call to `__chkstk`. In such a case, the CPSR could be clobbered, and the check invalidated. When the support was initially added, it seemed that the call would take care of preventing CPSR from being clobbered, but this is not the case. Mark the register as clobbered to fix a possible state corruption. llvm-svn: 311061
-rw-r--r--llvm/lib/Target/ARM/ARMISelLowering.cpp4
-rw-r--r--llvm/test/CodeGen/ARM/Windows/vla-cpsr.ll13
2 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 778ed3b26d2..ff8491d2e62 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -8790,6 +8790,8 @@ ARMTargetLowering::EmitLowered__chkstk(MachineInstr &MI,
.addReg(ARM::R4, RegState::Implicit | RegState::Kill)
.addReg(ARM::R4, RegState::Implicit | RegState::Define)
.addReg(ARM::R12,
+ RegState::Implicit | RegState::Define | RegState::Dead)
+ .addReg(ARM::CPSR,
RegState::Implicit | RegState::Define | RegState::Dead);
break;
case CodeModel::Large: {
@@ -8804,6 +8806,8 @@ ARMTargetLowering::EmitLowered__chkstk(MachineInstr &MI,
.addReg(ARM::R4, RegState::Implicit | RegState::Kill)
.addReg(ARM::R4, RegState::Implicit | RegState::Define)
.addReg(ARM::R12,
+ RegState::Implicit | RegState::Define | RegState::Dead)
+ .addReg(ARM::CPSR,
RegState::Implicit | RegState::Define | RegState::Dead);
break;
}
diff --git a/llvm/test/CodeGen/ARM/Windows/vla-cpsr.ll b/llvm/test/CodeGen/ARM/Windows/vla-cpsr.ll
new file mode 100644
index 00000000000..de0f0b68a4d
--- /dev/null
+++ b/llvm/test/CodeGen/ARM/Windows/vla-cpsr.ll
@@ -0,0 +1,13 @@
+; RUN: llc -mtriple thumbv7-windows-itanium -filetype asm -o /dev/null %s -print-machineinstrs=expand-isel-pseudos 2>&1 | FileCheck %s
+
+declare arm_aapcs_vfpcc void @g(i8*) local_unnamed_addr
+
+define arm_aapcs_vfpcc void @f(i32 %i) local_unnamed_addr {
+entry:
+ %vla = alloca i8, i32 %i, align 1
+ call arm_aapcs_vfpcc void @g(i8* nonnull %vla)
+ ret void
+}
+
+; CHECK: tBL pred:14, pred:%noreg, <es:__chkstk>, %LR<imp-def>, %SP<imp-use>, %R4<imp-use,kill>, %R4<imp-def>, %R12<imp-def,dead>, %CPSR<imp-def,dead>
+
OpenPOWER on IntegriCloud