Don't assume that the arguments are processed in some particular order.
authorChandler Carruth <chandlerc@gmail.com>
Thu, 15 Mar 2012 00:50:21 +0000 (00:50 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 15 Mar 2012 00:50:21 +0000 (00:50 +0000)
This appears to not be the case with dragonegg at least in some
contexts. Hopefully will fix the bootstrap assert failure there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152763 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/InlineCost.cpp

index fa683f695e7322d4ce4646ea58e8b8fe3030fc39..37aa729552bc2197dd2ba5592c29118a5887f866 100644 (file)
@@ -434,9 +434,11 @@ void InlineCostAnalyzer::FunctionInfo::countCodeReductionForPointerPair(
         = PointerArgs.find(OtherArg);
       if (ArgIt == PointerArgs.end())
         continue;
-      assert(ArgIt->second < ArgIdx);
+      std::pair<unsigned, unsigned> ArgPair(ArgIt->second, ArgIdx);
+      if (ArgIt->second > ArgIdx)
+        std::swap(ArgPair.first, ArgPair.second);
 
-      PointerArgPairWeights[std::make_pair(ArgIt->second, ArgIdx)]
+      PointerArgPairWeights[ArgPair]
         += countCodeReductionForConstant(Metrics, I);
     }
   } while (!Worklist.empty());