[llvm-commits] [llvm] r61536 - /llvm/trunk/include/llvm/CodeGen/ScheduleDAGSDNodes.h

Bill Wendling isanbard at gmail.com
Wed Dec 31 17:14:32 PST 2008


Author: void
Date: Wed Dec 31 19:14:31 2008
New Revision: 61536

URL: http://llvm.org/viewvc/llvm-project?rev=61536&view=rev
Log:
Some compilers are picky about accessing the first element of a std::vector if
there's nothing in the vector. Pacify them.

Modified:
    llvm/trunk/include/llvm/CodeGen/ScheduleDAGSDNodes.h

Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAGSDNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAGSDNodes.h?rev=61536&r1=61535&r2=61536&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/ScheduleDAGSDNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/ScheduleDAGSDNodes.h Wed Dec 31 19:14:31 2008
@@ -103,10 +103,13 @@
     ///
     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();
     }





More information about the llvm-commits mailing list