Some compilers are picky about accessing the first element of a std::vector if

there's nothing in the vector. Pacify them.

llvm-svn: 61536
This commit is contained in:
Bill Wendling 2009-01-01 01:14:31 +00:00
parent 163848021b
commit 4f8b265825
1 changed files with 5 additions and 2 deletions

View File

@ -103,10 +103,13 @@ namespace llvm {
///
SUnit *NewSUnit(SDNode *N) {
#ifndef NDEBUG
const SUnit *Addr = &SUnits[0];
const SUnit *Addr = 0;
if (SUnits.size() > 0)
Addr = &SUnits[0];
#endif
SUnits.push_back(SUnit(N, (unsigned)SUnits.size()));
assert(Addr == &SUnits[0] && "SUnits std::vector reallocated on the fly!");
assert((Addr == 0 || Addr == &SUnits[0]) &&
"SUnits std::vector reallocated on the fly!");
SUnits.back().OrigNode = &SUnits.back();
return &SUnits.back();
}