From: Wei Mi Date: Thu, 7 Apr 2016 05:27:17 +0000 (+0000) Subject: Fix the sanitizer bootstrap error in r265547. X-Git-Tag: llvmorg-3.9.0-rc1~9774 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=979e9756ecbcba1a1b4743048cb1193fb799bd53;p=platform%2Fupstream%2Fllvm.git Fix the sanitizer bootstrap error in r265547. The iterators of SmallPtrSet SpillsInSubTreeMap[Child].first may be invalidated when SpillsInSubTreeMap grows. Rearrange the code to ensure the grow of SpillsInSubTreeMap only happens before getting the iterators of the SmallPtrSet. llvm-svn: 265639 --- diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp index b88da60..81ebbcb 100644 --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -1272,10 +1272,17 @@ void HoistSpillHelper::runHoistSpills( unsigned NumChildren = Children.size(); for (unsigned i = 0; i != NumChildren; ++i) { MachineDomTreeNode *Child = Children[i]; + if (SpillsInSubTreeMap.find(Child) == SpillsInSubTreeMap.end()) + continue; + // SpillsInSubTreeMap[*RIt].second += SpillsInSubTreeMap[Child].second + // should be placed before getting the begin and end iterators of + // SpillsInSubTreeMap[Child].first, or else the iterators may be + // invalidated when SpillsInSubTreeMap[*RIt] is seen the first time + // and the map grows and then the original buckets in the map are moved. + SpillsInSubTreeMap[*RIt].second += SpillsInSubTreeMap[Child].second; auto BI = SpillsInSubTreeMap[Child].first.begin(); auto EI = SpillsInSubTreeMap[Child].first.end(); SpillsInSubTreeMap[*RIt].first.insert(BI, EI); - SpillsInSubTreeMap[*RIt].second += SpillsInSubTreeMap[Child].second; SpillsInSubTreeMap.erase(Child); }