diff options
author | Devang Patel <dpatel@apple.com> | 2007-04-16 21:28:14 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-04-16 21:28:14 +0000 |
commit | 3c1ca0b195ed50ba9492684841bd95e509cabe96 (patch) | |
tree | 1a98f0627a80ba1204b29ac026791933eefc8a47 /docs/WritingAnLLVMPass.html | |
parent | 3b317e5e7f5f2ed3e6537e367519a3440d3b6b1a (diff) | |
download | llvm-3c1ca0b195ed50ba9492684841bd95e509cabe96.tar.gz llvm-3c1ca0b195ed50ba9492684841bd95e509cabe96.tar.bz2 llvm-3c1ca0b195ed50ba9492684841bd95e509cabe96.tar.xz |
Document how, module pass can require function pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36171 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/WritingAnLLVMPass.html')
-rw-r--r-- | docs/WritingAnLLVMPass.html | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index 3b116074b7..c9813ef11c 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -466,7 +466,9 @@ class is the most general of all superclasses that you can use. Deriving from <tt>ModulePass</tt> 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 <tt>ModulePass</tt> -subclasses, no optimization can be done for their execution.</p> +subclasses, no optimization can be done for their execution. A module pass +can use function level passes (e.g. dominators) using getAnalysis interface +<tt> getAnalysis<DominatorTree>(Function)</tt>. </p> <p>To write a correct <tt>ModulePass</tt> subclass, derive from <tt>ModulePass</tt> and overload the <tt>runOnModule</tt> 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 <a href="#getAnalysisUsage"><tt>getAnalysisUsage</tt></a> implementation. This method can be called by your <tt>run*</tt> method implementation, or by any -other local method invoked by your <tt>run*</tt> method.</p> +other local method invoked by your <tt>run*</tt> method. + +A module level pass can use function level analysis info using this interface. +For example:</p> + +<div class="doc_code"><pre> + bool ModuleLevelPass::runOnModule(Module &M) { + ... + DominatorTree &DT = getAnalysis<DominatorTree>(Function &F); + ... + } +</pre></div> + +In above example, runOnFunction for DominatorTree is called by pass manager +before returning a reference to the desired pass.</p> <p> If your pass is capable of updating analyses if they exist (e.g., |