[PATCH] D25804: Fix 24560: assembler does not share constant pool for same constants

Weiming Zhao via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 14:21:56 PDT 2016


weimingz updated this revision to Diff 76481.
weimingz added a comment.

Use find/end as David suggested


Repository:
  rL LLVM

https://reviews.llvm.org/D25804

Files:
  lib/MC/ConstantPools.cpp


Index: lib/MC/ConstantPools.cpp
===================================================================
--- lib/MC/ConstantPools.cpp
+++ lib/MC/ConstantPools.cpp
@@ -37,8 +37,12 @@
 const MCExpr *ConstantPool::addEntry(const MCExpr *Value, MCContext &Context,
                                      unsigned Size, SMLoc Loc) {
   const MCConstantExpr *C = dyn_cast<MCConstantExpr>(Value);
-  if (C && CachedEntries.count(C->getValue()))
-    return CachedEntries[C->getValue()];
+
+  // Check if there is existing entry for the same constant. If so, reuse it.
+  auto Itr = C ? CachedEntries.find(C->getValue()) : CachedEntries.end();
+  if (Itr != CachedEntries.end())
+    return Itr->second;
+
   MCSymbol *CPEntryLabel = Context.createTempSymbol();
 
   Entries.push_back(ConstantPoolEntry(CPEntryLabel, Value, Size, Loc));


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25804.76481.patch
Type: text/x-patch
Size: 823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161031/e176b690/attachment.bin>


More information about the llvm-commits mailing list