From 9b5e8e5c32b68e2f7c337f9a7e59de04c7fd5737 Mon Sep 17 00:00:00 2001
From: Devang Patel
Date: Mon, 16 Apr 2007 21:28:14 +0000
Subject: Document how, module pass can require function pass.
llvm-svn: 36171
---
llvm/docs/WritingAnLLVMPass.html | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
(limited to 'llvm/docs/WritingAnLLVMPass.html')
diff --git a/llvm/docs/WritingAnLLVMPass.html b/llvm/docs/WritingAnLLVMPass.html
index 3b116074b71..c9813ef11c5 100644
--- a/llvm/docs/WritingAnLLVMPass.html
+++ b/llvm/docs/WritingAnLLVMPass.html
@@ -466,7 +466,9 @@ 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.
+subclasses, no optimization can be done for their execution. A module pass
+can use function level passes (e.g. dominators) using getAnalysis interface
+ getAnalysis(Function).
To write a correct ModulePass subclass, derive from
ModulePass and overload the runOnModule method with the
@@ -1127,7 +1129,21 @@ runtime assertion failure if you attempt to get an analysis that you did not
declare as required in your getAnalysisUsage implementation. This
method can be called by your run* method implementation, or by any
-other local method invoked by your run* method.
+other local method invoked by your run* method.
+
+A module level pass can use function level analysis info using this interface.
+For example:
+
+
+ bool ModuleLevelPass::runOnModule(Module &M) {
+ ...
+ DominatorTree &DT = getAnalysis<DominatorTree>(Function &F);
+ ...
+ }
+
+
+In above example, runOnFunction for DominatorTree is called by pass manager
+before returning a reference to the desired pass.
If your pass is capable of updating analyses if they exist (e.g.,
--
cgit v1.2.3