mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-18 12:29:21 +00:00
don't access element zero of an array of size zero.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45526 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
50cffa0107
commit
9848ced5d0
@ -108,10 +108,10 @@ public:
|
|||||||
unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
|
unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
|
||||||
assert(RegClass && "Cannot create register without RegClass!");
|
assert(RegClass && "Cannot create register without RegClass!");
|
||||||
// Add a reg, but keep track of whether the vector reallocated or not.
|
// Add a reg, but keep track of whether the vector reallocated or not.
|
||||||
void *ArrayBase = &VRegInfo[0];
|
void *ArrayBase = VRegInfo.empty() ? 0 : &VRegInfo[0];
|
||||||
VRegInfo.push_back(std::make_pair(RegClass, (MachineOperand*)0));
|
VRegInfo.push_back(std::make_pair(RegClass, (MachineOperand*)0));
|
||||||
|
|
||||||
if (&VRegInfo[0] == ArrayBase)
|
if (&VRegInfo[0] == ArrayBase || VRegInfo.size() == 1)
|
||||||
return getLastVirtReg();
|
return getLastVirtReg();
|
||||||
|
|
||||||
// Otherwise, the vector reallocated, handle this now.
|
// Otherwise, the vector reallocated, handle this now.
|
||||||
|
Loading…
Reference in New Issue
Block a user