[llvm-commits] [llvm] r45526 - /llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
Chris Lattner
sabre at nondot.org
Wed Jan 2 17:25:32 PST 2008
Author: lattner
Date: Wed Jan 2 19:25:31 2008
New Revision: 45526
URL: http://llvm.org/viewvc/llvm-project?rev=45526&view=rev
Log:
don't access element zero of an array of size zero.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=45526&r1=45525&r2=45526&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Wed Jan 2 19:25:31 2008
@@ -108,10 +108,10 @@
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.
More information about the llvm-commits
mailing list