aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/CodeGen/MachineRegisterInfo.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h
index 81eb69414a..8af42b7cf5 100644
--- a/include/llvm/CodeGen/MachineRegisterInfo.h
+++ b/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -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.