ElectricFence found this bug where we were reading past the vector boundary.
authorMisha Brukman <brukman+llvm@gmail.com>
Mon, 4 Aug 2003 23:48:40 +0000 (23:48 +0000)
committerMisha Brukman <brukman+llvm@gmail.com>
Mon, 4 Aug 2003 23:48:40 +0000 (23:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7585 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/TargetSchedInfo.cpp

index d64652398ae7421eb8b7cb7e5220ecf127b4377b..a52f7886d3086627a5615a6f16f550110efec161 100644 (file)
@@ -243,7 +243,7 @@ void InstrRUsage::addUsageDelta(const InstrRUsageDelta &delta) {
        // for that resource in each cycle.
        std::vector<resourceId_t>& rvec = this->resourcesByCycle[c];
        int r;
-       for (r = (int) rvec.size(); r >= 0; r--)
+       for (r = rvec.size() - 1; r >= 0; r--)
          if (rvec[r] == delta.resourceId)
            {// found last entry for the resource
              rvec.erase(rvec.begin() + r);