diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -355,8 +355,9 @@ static Constant *getFoldedSizeOf(Type *Ty, Type *DestTy, bool Folded, DenseMap &Cache) { // Check for previously generated folded size constant. - if (Cache.find(Ty) != Cache.end()) - return Cache[Ty]; + auto CacheIter = Cache.find(Ty); + if (CacheIter != Cache.end()) + return CacheIter->second; if (ArrayType *ATy = dyn_cast(Ty)) { Constant *N = ConstantInt::get(DestTy, ATy->getNumElements());