[llvm-commits] CVS: llvm/docs/WritingAnLLVMPass.html
Devang Patel
dpatel at apple.com
Tue May 1 13:55:58 PDT 2007
Changes in directory llvm/docs:
WritingAnLLVMPass.html updated: 1.56 -> 1.57
---
Log message:
Update doc to reflect changes I am about to install to fix PR 888: http://llvm.org/PR888 .
---
Diffs of the changes: (+20 -1)
WritingAnLLVMPass.html | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletion(-)
Index: llvm/docs/WritingAnLLVMPass.html
diff -u llvm/docs/WritingAnLLVMPass.html:1.56 llvm/docs/WritingAnLLVMPass.html:1.57
--- llvm/docs/WritingAnLLVMPass.html:1.56 Mon Apr 16 19:17:11 2007
+++ llvm/docs/WritingAnLLVMPass.html Tue May 1 15:55:38 2007
@@ -263,6 +263,14 @@
time.</p>
<div class="doc_code"><pre>
+ static const int ID;
+ Hello() : FunctionPass((intptr_t)&ID) {}
+</pre></div><p>
+
+<p> This declares pass identifier used by LLVM to identify pass. This allows LLVM to
+avoid using expensive C++ runtime information.</p>
+
+<div class="doc_code"><pre>
<b>virtual bool</b> <a href="#runOnFunction">runOnFunction</a>(Function &F) {
llvm::cerr << "<i>Hello: </i>" << F.getName() << "\n";
<b>return false</b>;
@@ -277,6 +285,13 @@
function.</p>
<div class="doc_code"><pre>
+ const int Hello::ID = 0;
+</pre></div>
+
+<p> We initialize pass ID here. LLVM uses ID's address to identify pass so
+initialization value is not important.</p>
+
+<div class="doc_code"><pre>
RegisterPass<Hello> X("<i>hello</i>", "<i>Hello World Pass</i>");
} <i>// end of anonymous namespace</i>
</pre></div>
@@ -295,6 +310,10 @@
<b>namespace</b> {
<b>struct Hello</b> : <b>public</b> <a href="#FunctionPass">FunctionPass</a> {
+
+ static const int ID;
+ Hello() : FunctionPass((intptr_t)&ID) {}
+
<b>virtual bool</b> <a href="#runOnFunction">runOnFunction</a>(Function &F) {
llvm::cerr << "<i>Hello: </i>" << F.getName() << "\n";
<b>return false</b>;
@@ -1788,7 +1807,7 @@
<a href="mailto:sabre at nondot.org">Chris Lattner</a><br>
<a href="http://llvm.org">The LLVM Compiler Infrastructure</a><br>
- Last modified: $Date: 2007/04/17 00:17:11 $
+ Last modified: $Date: 2007/05/01 20:55:38 $
</address>
</body>
More information about the llvm-commits
mailing list