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;