[PATCH] D6594: Fix for bug 8281 - Extremely slow assembling and disassembling of ptrtoint

Chenguang Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 21:27:23 PST 2021


wecing updated this revision to Diff 321919.
wecing added a comment.

Avoid redundant map indexing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D6594/new/

https://reviews.llvm.org/D6594

Files:
  llvm/lib/IR/ConstantFold.cpp


Index: llvm/lib/IR/ConstantFold.cpp
===================================================================
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -355,8 +355,9 @@
 static Constant *getFoldedSizeOf(Type *Ty, Type *DestTy, bool Folded,
                                  DenseMap<Type *, Constant *> &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<ArrayType>(Ty)) {
     Constant *N = ConstantInt::get(DestTy, ATy->getNumElements());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6594.321919.patch
Type: text/x-patch
Size: 675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210206/cc63f43f/attachment.bin>


More information about the llvm-commits mailing list