From: Dan Gohman Date: Fri, 29 Oct 2010 20:16:10 +0000 (+0000) Subject: Make ScalarEvolution::forgetLoop forget all contained loops too, because X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e60dcb5e974989998f1d008ea2a1caee29665d58;p=oota-llvm.git Make ScalarEvolution::forgetLoop forget all contained loops too, because they may have ValuesAtScopes map entries referencing their outer loops. This fixes a user-after-free reported in PR8471. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117698 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 5ae273e56d2..4d750b4464b 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -3781,6 +3781,11 @@ void ScalarEvolution::forgetLoop(const Loop *L) { PushDefUseChildren(I, Worklist); } + + // Forget all contained loops too, to avoid dangling entries in the + // ValuesAtScopes map. + for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) + forgetLoop(*I); } /// forgetValue - This method should be called by the client when it has