From e50fb9ac174b791047ffa8648443ab94b2097cd9 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 1 May 2007 20:55:38 +0000 Subject: [PATCH] Update doc to reflect changes I am about to install to fix PR 888. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36631 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/WritingAnLLVMPass.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index 8f2c7af1aa4..13849d0dba1 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -262,6 +262,14 @@ href="#passtype">later, but for now, know that FunctionPass's operate a function at a time.

+
+     static const int ID;
+     Hello() : FunctionPass((intptr_t)&ID) {}
+

+ +

This declares pass identifier used by LLVM to identify pass. This allows LLVM to +avoid using expensive C++ runtime information.

+
     virtual bool runOnFunction(Function &F) {
       llvm::cerr << "Hello: " << F.getName() << "\n";
@@ -276,6 +284,13 @@ href="#FunctionPass">FunctionPass.  This is where we are supposed
 to do our thing, so we just print out our message with the name of each
 function.

+
+  const int Hello::ID = 0;
+
+ +

We initialize pass ID here. LLVM uses ID's address to identify pass so +initialization value is not important.

+
   RegisterPass<Hello> X("hello", "Hello World Pass");
 }  // end of anonymous namespace
@@ -295,6 +310,10 @@ argument "hello", and a name "Hello World Pass".

namespace { struct Hello : public FunctionPass { + + static const int ID; + Hello() : FunctionPass((intptr_t)&ID) {} + virtual bool runOnFunction(Function &F) { llvm::cerr << "Hello: " << F.getName() << "\n"; return false; -- 2.34.1