Index: lib/Transforms/Scalar/LICM.cpp =================================================================== --- lib/Transforms/Scalar/LICM.cpp +++ lib/Transforms/Scalar/LICM.cpp @@ -202,21 +202,28 @@ assert(L->isLCSSAForm(*DT) && "Loop is not in LCSSA form."); - CurAST = new AliasSetTracker(*AA); + CurAST = nullptr; // Collect Alias info from subloops. for (Loop *InnerL : L->getSubLoops()) { AliasSetTracker *InnerAST = LoopToAliasSetMap[InnerL]; assert(InnerAST && "Where is my AST?"); - // What if InnerLoop was modified by other passes ? - CurAST->add(*InnerAST); + if (CurAST != nullptr) { + // What if InnerLoop was modified by other passes ? + CurAST->add(*InnerAST); - // Once we've incorporated the inner loop's AST into ours, we don't need the - // subloop's anymore. - delete InnerAST; + // Once we've incorporated the inner loop's AST into ours, we don't need + // the subloop's anymore. + delete InnerAST; + } else { + CurAST = InnerAST; + } LoopToAliasSetMap.erase(InnerL); } + if (CurAST == nullptr) + CurAST = new AliasSetTracker(*AA); + CurLoop = L; // Get the preheader block to move instructions into...