Hello,<br>I was trying to interface a custom backend instruction scheduler with llvm code when I realize something terrible. The scheduling code builds a graph made up of SUnit * nodes (see ScheduleDAG*.{cpp,h}). These SUnits nodes are allocated via a std::vector< SUnit >.<br>

This isn't a problem as long as the pointers are taken after the vector is fully filled and the vector never changes its size. But the problem is that is can happen !<br>Indeed, in some rare cases, the scheduler needs to duplicate a SUnit and thus allocate a new one. This gives code this:<br>

<br>ScheduleDAGSNodes.cpp:<br><br>#ifndef NDEBUG<br>  const SUnit *Addr = 0;<br>  if (!SUnits.empty())<br>    Addr = &SUnits[0];<br>#endif<br>  SUnits.push_back(SUnit(N, (unsigned)SUnits.size()));<br>  assert((Addr == 0 || Addr == &SUnits[0]) &&<br>

<br>Not only this code does not compile with NDEBUG set but it could trigger an extermely reliable assertion failure in some cases. One could think that this is too rare to happen but it does happen with my scheduler and I'm not quite embarassed because I can't do anything apart from hacking llvm source code. I feel that triggering an assertion failure just because the user made the mistake of having not luck is not great for such a big framework as LLVM :)<br>

<br>Shouldn't LLVM use a custom vector implementation for such cases, an implementation that does not invalidate pointers when growing ?<br>I have such an implementation at hand that I'm willing to provide if needed.<br>

<br>Regards<br><br><br clear="all">Amaury Pouly<br>