aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFrameInfo.cpp
diff options
context:
space:
mode:
authorKiran Chandramohan <kiran.chandramohan@arm.com>2019-11-20 12:45:26 +0000
committerKiran Chandramohan <kiran.chandramohan@arm.com>2019-12-10 11:44:41 +0000
commit965ed1e974e80e0b96ac3921e8a915e8e46baa5c (patch)
tree978976b5372c4ec27c485dbbdd5d18e2547b44ca /llvm/lib/CodeGen/MachineFrameInfo.cpp
parentb2508ce85c1e39cd32e8bb1071297d5840a32541 (diff)
downloadllvm-965ed1e974e80e0b96ac3921e8a915e8e46baa5c.zip
llvm-965ed1e974e80e0b96ac3921e8a915e8e46baa5c.tar.gz
llvm-965ed1e974e80e0b96ac3921e8a915e8e46baa5c.tar.bz2
[AArch64] Fix issues with large arrays on stack
Summary: This patch fixes a few issues when large arrays are allocated on the stack. Currently, clang has inconsistent behaviour, for debug builds there is an assertion failure when the array size on stack is around 2GB but there is no assertion when the stack is around 8GB. For release builds there is no assertion, the compilation succeeds but generates incorrect code. The incorrect code generated is due to using int/unsigned int instead of their 64-bit counterparts. This patch, 1) Removes the assertion in frame legality check. 2) Converts int/unsigned int in some places to the 64-bit variants. This helps in generating correct code and removes the inconsistent behaviour. 3) Adds a test which runs without optimisations. Reviewers: sdesmalen, efriedma, fhahn, aemerson Reviewed By: efriedma Subscribers: eli.friedman, fpetrogalli, kristof.beyls, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70496
Diffstat (limited to 'llvm/lib/CodeGen/MachineFrameInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFrameInfo.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineFrameInfo.cpp b/llvm/lib/CodeGen/MachineFrameInfo.cpp
index 604f514..22ab2c7 100644
--- a/llvm/lib/CodeGen/MachineFrameInfo.cpp
+++ b/llvm/lib/CodeGen/MachineFrameInfo.cpp
@@ -133,11 +133,11 @@ BitVector MachineFrameInfo::getPristineRegs(const MachineFunction &MF) const {
return BV;
}
-unsigned MachineFrameInfo::estimateStackSize(const MachineFunction &MF) const {
+uint64_t MachineFrameInfo::estimateStackSize(const MachineFunction &MF) const {
const TargetFrameLowering *TFI = MF.getSubtarget().getFrameLowering();
const TargetRegisterInfo *RegInfo = MF.getSubtarget().getRegisterInfo();
unsigned MaxAlign = getMaxAlignment();
- int Offset = 0;
+ int64_t Offset = 0;
// This code is very, very similar to PEI::calculateFrameObjectOffsets().
// It really should be refactored to share code. Until then, changes
@@ -147,7 +147,7 @@ unsigned MachineFrameInfo::estimateStackSize(const MachineFunction &MF) const {
// Only estimate stack size of default stack.
if (getStackID(i) != TargetStackID::Default)
continue;
- int FixedOff = -getObjectOffset(i);
+ int64_t FixedOff = -getObjectOffset(i);
if (FixedOff > Offset) Offset = FixedOff;
}
for (unsigned i = 0, e = getObjectIndexEnd(); i != e; ++i) {
@@ -183,7 +183,7 @@ unsigned MachineFrameInfo::estimateStackSize(const MachineFunction &MF) const {
unsigned AlignMask = StackAlign - 1;
Offset = (Offset + AlignMask) & ~uint64_t(AlignMask);
- return (unsigned)Offset;
+ return (uint64_t)Offset;
}
void MachineFrameInfo::computeMaxCallFrameSize(const MachineFunction &MF) {