From f76b7f22f085fbf9f2585923f7a3a0558d75964b Mon Sep 17 00:00:00 2001 From: Mircea Trofin Date: Fri, 11 Dec 2020 20:28:39 -0800 Subject: [PATCH 1/2] [MLGO] Fix build break as result of new InstructionCost (D91174) --- llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp b/llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp index 2213cd8598b0a0..3c90e82fb952bf 100644 --- a/llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp +++ b/llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp @@ -130,8 +130,8 @@ size_t getSize(Function &F, TargetTransformInfo &TTI) { size_t Ret = 0; for (const auto &BB : F) for (const auto &I : BB) - Ret += TTI.getInstructionCost( - &I, TargetTransformInfo::TargetCostKind::TCK_CodeSize); + Ret += *(TTI.getInstructionCost( + &I, TargetTransformInfo::TargetCostKind::TCK_CodeSize).getValue()); return Ret; } From eb44682d671d66e422b02595a636050582a4d84a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 11 Dec 2020 21:19:31 -0800 Subject: [PATCH 2/2] [Analysis] Use is_contained (NFC) --- llvm/lib/Analysis/CFG.cpp | 2 +- llvm/lib/Analysis/InstructionSimplify.cpp | 2 +- llvm/lib/Analysis/LazyValueInfo.cpp | 2 +- llvm/lib/Analysis/ScalarEvolution.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Analysis/CFG.cpp b/llvm/lib/Analysis/CFG.cpp index d87da3d8f8a7ce..33602ed71675c6 100644 --- a/llvm/lib/Analysis/CFG.cpp +++ b/llvm/lib/Analysis/CFG.cpp @@ -103,7 +103,7 @@ bool llvm::isCriticalEdge(const Instruction *TI, const BasicBlock *Dest, assert(TI->isTerminator() && "Must be a terminator to have successors!"); if (TI->getNumSuccessors() == 1) return false; - assert(find(predecessors(Dest), TI->getParent()) != pred_end(Dest) && + assert(is_contained(predecessors(Dest), TI->getParent()) && "No edge between TI's block and Dest."); const_pred_iterator I = pred_begin(Dest), E = pred_end(Dest); diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 6b116eb0ed000b..35c21a023bae43 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4669,7 +4669,7 @@ static Value *SimplifyShuffleVectorInst(Value *Op0, Value *Op1, // Don't fold a shuffle with undef mask elements. This may get folded in a // better way using demanded bits or other analysis. // TODO: Should we allow this? - if (find(Indices, -1) != Indices.end()) + if (is_contained(Indices, -1)) return nullptr; // Check if every element of this shuffle can be mapped back to the diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 5a4db49a2bcbdd..a2f0bd872573ea 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -1244,7 +1244,7 @@ ValueLatticeElement getValueFromCondition(Value *Val, Value *Cond, // Return true if Usr has Op as an operand, otherwise false. static bool usesOperand(User *Usr, Value *Op) { - return find(Usr->operands(), Op) != Usr->op_end(); + return is_contained(Usr->operands(), Op); } // Return true if the instruction type of Val is supported by diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 53fd668be05cda..3005a44b44eff2 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -10639,7 +10639,7 @@ static bool IsMinMaxConsistingOf(const SCEV *MaybeMinMaxExpr, if (!MinMaxExpr) return false; - return find(MinMaxExpr->operands(), Candidate) != MinMaxExpr->op_end(); + return is_contained(MinMaxExpr->operands(), Candidate); } static bool IsKnownPredicateViaAddRecStart(ScalarEvolution &SE,