From b7750c5325d8bb3260462b21ee46e2dc675c6a3c Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 1 Jul 2009 23:38:44 +0000 Subject: Try to clarify a point about getting DominatorTree info from a module pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74668 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/WritingAnLLVMPass.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'docs/WritingAnLLVMPass.html') diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index 8374bfa..b8ac9e9 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -491,10 +491,15 @@ class is the most general of all superclasses that you can use. Deriving from ModulePass indicates that your pass uses the entire program as a unit, refering to function bodies in no predictable order, or adding and removing functions. Because nothing is known about the behavior of ModulePass -subclasses, no optimization can be done for their execution. A module pass -can use function level passes (e.g. dominators) using getAnalysis interface - getAnalysis<DominatorTree>(Function), if the function pass -does not require any module passes.

+subclasses, no optimization can be done for their execution.

+ +

A module pass can use function level passes (e.g. dominators) using +the getAnalysis interface +getAnalysis<DominatorTree>(llvm::Function *) to provide the +function to retrieve analysis result for, if the function pass does not require +any module passes. Note that this can only be done for functions for which the +analysis ran, e.g. in the case of dominators you should only ask for the +DominatorTree for function definitions, not declarations.

To write a correct ModulePass subclass, derive from ModulePass and overload the runOnModule method with the -- cgit v1.1