don't access element zero of an array of size zero.

llvm-svn: 45526
This commit is contained in:
Chris Lattner 2008-01-03 01:25:31 +00:00
parent 76719ba5f1
commit e35604ddb2
1 changed files with 2 additions and 2 deletions

View File

@ -108,10 +108,10 @@ public:
unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
assert(RegClass && "Cannot create register without RegClass!");
// 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));
if (&VRegInfo[0] == ArrayBase)
if (&VRegInfo[0] == ArrayBase || VRegInfo.size() == 1)
return getLastVirtReg();
// Otherwise, the vector reallocated, handle this now.