[PATCH] MemoryDependenceAnalysis always depends on DominatorTree

Evan Cheng evan.cheng at apple.com
Fri Mar 29 15:39:24 PDT 2013


On Mar 27, 2013, at 5:44 PM, Matt Arsenault <Matthew.Arsenault at amd.com> wrote:

> Hi nlewycky,
> 
> The DominatorTree was optional, but the uses of the tree aren't checked, causing it to crash when not available.
> 
> I've made DominatorTree required, although I'm not sure if it would be better to put the checks before its uses instead.

Adding the checks before DT is used is probably the better fix. Can you try that? Also, please include a test case.

Evan

> 
> http://llvm-reviews.chandlerc.com/D583
> 
> Files:
>  lib/Analysis/MemoryDependenceAnalysis.cpp
> 
> Index: lib/Analysis/MemoryDependenceAnalysis.cpp
> ===================================================================
> --- lib/Analysis/MemoryDependenceAnalysis.cpp
> +++ lib/Analysis/MemoryDependenceAnalysis.cpp
> @@ -56,6 +56,7 @@
> // Register this pass...
> INITIALIZE_PASS_BEGIN(MemoryDependenceAnalysis, "memdep",
>                 "Memory Dependence Analysis", false, true)
> +INITIALIZE_PASS_DEPENDENCY(DominatorTree)
> INITIALIZE_AG_DEPENDENCY(AliasAnalysis)
> INITIALIZE_PASS_END(MemoryDependenceAnalysis, "memdep",
>                       "Memory Dependence Analysis", false, true)
> @@ -85,12 +86,13 @@
> void MemoryDependenceAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
>   AU.setPreservesAll();
>   AU.addRequiredTransitive<AliasAnalysis>();
> +  AU.addRequired<DominatorTree>();
> }
> 
> bool MemoryDependenceAnalysis::runOnFunction(Function &) {
>   AA = &getAnalysis<AliasAnalysis>();
>   TD = getAnalysisIfAvailable<DataLayout>();
> -  DT = getAnalysisIfAvailable<DominatorTree>();
> +  DT = &getAnalysis<DominatorTree>();
>   if (PredCache == 0)
>     PredCache.reset(new PredIteratorCache());
>   return false;
> <D583.1.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list