From 6acdca78a08cc8b699e3618c7e1c5d2d8e797c20 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 24 Jan 2017 12:55:57 +0000 Subject: [PH] Replace uses of AssertingVH from members of analysis results with a lazy-asserting PoisoningVH. AssertVH is fundamentally incompatible with cache-invalidation of analysis results. The invaliadtion happens after the AssertingVH has already fired. Instead, use a PoisoningVH that will assert if the dangling handle is ever used rather than merely be assigned or destroyed. This patch also removes all of the (numerous) doomed attempts to work around this fundamental incompatibility. It is a pretty significant simplification IMO. The most interesting change is in the Inliner where we still do some clearing because we don't want to rely on the coarse grained invalidation strategy of the containing pass manager. However, I prefer the approach that contains this logic to the cleanup phase of the Inliner, and I think we could enhance the CGSCC analysis management layer to make this even better in the future if desired. The rest is straight cleanup. I've also added a test for one of the harder cases to work around: when a *module analysis* contains many AssertingVHes pointing at functions. Differential Revision: https://reviews.llvm.org/D29006 llvm-svn: 292928 --- llvm/lib/Transforms/IPO/GlobalDCE.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'llvm/lib/Transforms/IPO/GlobalDCE.cpp') diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index 9304e783d49..67e9d20eb92 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp @@ -144,29 +144,13 @@ PreservedAnalyses GlobalDCEPass::run(Module &M, ModuleAnalysisManager &MAM) { } } - // Because we may have cached analyses for functions we take extra care when - // deleting them if there is an active proxy. If there isn't, then we get to - // assume that everything in the function AM has been cleared already. - // FIXME: Note that all of this will happen automatically when this pass - // finishes. Unfortuantely there are analyses which hold asserting VHs to - // IR units. We could make those weak VHs that would assert if ever used - // without asserting eagerly and then all of this knowledge of the analysis - // manager could go away. - FunctionAnalysisManager *FAM = nullptr; - if (auto *FAMProxy = - MAM.getCachedResult(M)) - FAM = &FAMProxy->getManager(); - // The second pass drops the bodies of functions which are dead... std::vector DeadFunctions; for (Function &F : M) if (!AliveGlobals.count(&F)) { DeadFunctions.push_back(&F); // Keep track of dead globals - if (!F.isDeclaration()) { - if (FAM) - FAM->clear(F); + if (!F.isDeclaration()) F.deleteBody(); - } } // The third pass drops targets of aliases which are dead... -- cgit v1.2.3