[llvm] r265639 - Fix the sanitizer bootstrap error in r265547.
Wei Mi via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 22:27:17 PDT 2016
Author: wmi
Date: Thu Apr 7 00:27:17 2016
New Revision: 265639
URL: http://llvm.org/viewvc/llvm-project?rev=265639&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/InlineSpiller.cpp
Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=265639&r1=265638&r2=265639&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original)
+++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Thu Apr 7 00:27:17 2016
@@ -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);
}
More information about the llvm-commits
mailing list