[PATCH] D50573: [LegacyPassManager] Remove analysis P from AnUsageMap before deleting it in schedulePass.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 10 10:52:50 PDT 2018


craig.topper created this revision.
craig.topper added reviewers: chandlerc, nlopes, reames.
Herald added a subscriber: mehdi_amini.

If we deem the analysis pass useless and delete it, we need to make sure we remove it from AnUsageMap. Otherwise we might allocate another pass in the freed memory. This will cause us to reuse the AnalysisUsage from the original pass instead of the new one.

Fixes PR38511


https://reviews.llvm.org/D50573

Files:
  lib/IR/LegacyPassManager.cpp


Index: lib/IR/LegacyPassManager.cpp
===================================================================
--- lib/IR/LegacyPassManager.cpp
+++ lib/IR/LegacyPassManager.cpp
@@ -677,6 +677,8 @@
   // available at this point.
   const PassInfo *PI = findAnalysisPassInfo(P->getPassID());
   if (PI && PI->isAnalysis() && findAnalysisPass(P->getPassID())) {
+    // Remove any cached AnalysisUsage information.
+    AnUsageMap.erase(P);
     delete P;
     return;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50573.160145.patch
Type: text/x-patch
Size: 464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180810/79951e53/attachment.bin>


More information about the llvm-commits mailing list