Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:
[oota-llvm.git] / lib / Transforms / Utils / LowerExpectIntrinsic.cpp
index df8d68ec8bab2ce2e2b889a980a6eb49418b3f3f..0e9cdf55b242d977d01f7af3622045845a0522f8 100644 (file)
@@ -73,16 +73,16 @@ bool LowerExpectIntrinsic::HandleSwitchExpect(SwitchInst *SI) {
   LLVMContext &Context = CI->getContext();
   Type *Int32Ty = Type::getInt32Ty(Context);
 
-  unsigned caseNo = SI->findCaseValue(ExpectedValue);
+  SwitchInst::CaseIt Case = SI->findCaseValue(ExpectedValue);
   std::vector<Value *> Vec;
   unsigned n = SI->getNumCases();
   Vec.resize(n + 1 + 1); // +1 for MDString and +1 for default case
 
   Vec[0] = MDString::get(Context, "branch_weights");
-  Vec[1] = ConstantInt::get(Int32Ty, SwitchInst::ErrorIndex == caseNo ?
+  Vec[1] = ConstantInt::get(Int32Ty, Case == SI->caseDefault() ?
                             LikelyBranchWeight : UnlikelyBranchWeight);
   for (unsigned i = 0; i < n; ++i) {
-    Vec[i + 1 + 1] = ConstantInt::get(Int32Ty, i == caseNo ?
+    Vec[i + 1 + 1] = ConstantInt::get(Int32Ty, i == Case.getCaseIndex() ?
         LikelyBranchWeight : UnlikelyBranchWeight);
   }