[PATCH] D10877: [BitcodeReader] Fix for PR23310: llvm-dis crashes when trying to upgrade an intrinsic.

Philip Pfaffe philip.pfaffe at gmail.com
Thu Jul 2 09:06:27 PDT 2015


philip.pfaffe updated this revision to Diff 28952.
philip.pfaffe added a comment.

Added git diff --binary


http://reviews.llvm.org/D10877

Files:
  lib/Bitcode/Reader/BitcodeReader.cpp
  test/Bitcode/Inputs/PR23310.bc
  test/Bitcode/PR23310.test

Index: test/Bitcode/PR23310.test
===================================================================
--- /dev/null
+++ test/Bitcode/PR23310.test
@@ -0,0 +1 @@
+RUN: llvm-dis -disable-output %p/Inputs/PR23310.bc
Index: lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- lib/Bitcode/Reader/BitcodeReader.cpp
+++ lib/Bitcode/Reader/BitcodeReader.cpp
@@ -170,7 +170,7 @@
 
   // When intrinsic functions are encountered which require upgrading they are
   // stored here with their replacement function.
-  typedef std::vector<std::pair<Function*, Function*> > UpgradedIntrinsicMap;
+  typedef DenseMap<Function*, Function*> UpgradedIntrinsicMap;
   UpgradedIntrinsicMap UpgradedIntrinsics;
 
   // Map the bitcode's custom MDKind ID to the Module's MDKind ID.
@@ -2710,7 +2710,7 @@
   for (Function &F : *TheModule) {
     Function *NewFn;
     if (UpgradeIntrinsicFunction(&F, NewFn))
-      UpgradedIntrinsics.push_back(std::make_pair(&F, NewFn));
+      UpgradedIntrinsics[&F] = NewFn;
   }
 
   // Look for global variables which need to be renamed.
@@ -4540,7 +4540,7 @@
       I.first->eraseFromParent();
     }
   }
-  std::vector<std::pair<Function*, Function*> >().swap(UpgradedIntrinsics);
+  UpgradedIntrinsics.clear();
 
   for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
     UpgradeInstWithTBAATag(InstsWithTBAATag[I]);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10877.28952.patch
Type: text/x-patch
Size: 1403 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150702/684828bc/attachment.bin>


More information about the llvm-commits mailing list