Avoid read after free.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 16 Apr 2008 01:22:28 +0000 (01:22 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 16 Apr 2008 01:22:28 +0000 (01:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49760 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SimpleRegisterCoalescing.cpp

index 4ea1ae7e10e0335fc1f3e92493e03e5f5f151381..cac10c4e0b32b7c6e813360828d91f0c99476e89 100644 (file)
@@ -553,7 +553,6 @@ static void removeRange(LiveInterval &li, unsigned Start, unsigned End,
 static void removeIntervalIfEmpty(LiveInterval &li, LiveIntervals *li_,
                                   const TargetRegisterInfo *tri_) {
   if (li.empty()) {
-    li_->removeInterval(li.reg);
     if (TargetRegisterInfo::isPhysicalRegister(li.reg))
       for (const unsigned* SR = tri_->getSubRegisters(li.reg); *SR; ++SR) {
         if (!li_->hasInterval(*SR))
@@ -562,6 +561,7 @@ static void removeIntervalIfEmpty(LiveInterval &li, LiveIntervals *li_,
         if (sli.empty())
           li_->removeInterval(*SR);
       }
+    li_->removeInterval(li.reg);
   }
 }