[PATCH] D11236: ScalarEvolution: Make required passes transitive to prevent dangling pointers

Steve King kingshizzle at gmail.com
Wed Jul 15 12:19:13 PDT 2015


srking created this revision.
srking added a subscriber: llvm-commits.

ScalarEvolution stores long lived raw pointers to objects owned by unique_ptrs in other passes.  In ScalarEvolution, change addRequired() to addRequiredTransitive() to prevent required passes from being freed and thus preven dangling raw pointers.

IMHO, the current design needs a FIXME to eliminate the long lived raw pointers altogether.  Barring that, some way to assert() if the raw pointers becomes dangling would help.

http://reviews.llvm.org/D11236

Files:
  lib/Analysis/ScalarEvolution.cpp

Index: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ lib/Analysis/ScalarEvolution.cpp
@@ -8107,10 +8107,10 @@
 
 void ScalarEvolution::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.setPreservesAll();
-  AU.addRequired<AssumptionCacheTracker>();
+  AU.addRequiredTransitive<AssumptionCacheTracker>();
   AU.addRequiredTransitive<LoopInfoWrapperPass>();
   AU.addRequiredTransitive<DominatorTreeWrapperPass>();
-  AU.addRequired<TargetLibraryInfoWrapperPass>();
+  AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>();
 }
 
 bool ScalarEvolution::hasLoopInvariantBackedgeTakenCount(const Loop *L) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11236.29812.patch
Type: text/x-patch
Size: 701 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150715/c3548d21/attachment.bin>


More information about the llvm-commits mailing list