From 5e09eefe95eb9fde26879e43ef9c2704505dc6f2 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Sat, 1 Jan 2011 17:37:07 +0000 Subject: [PATCH] Correct a bunch of mistakes which meant that the example pass didn't even compile, let alone work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122657 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/WritingAnLLVMPass.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index ae8b8d5bfa..d0aeeec1fc 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -273,7 +273,7 @@ time.

      static char ID;
-     Hello() : FunctionPass(&ID) {}
+     Hello() : FunctionPass(ID) {}
 

This declares pass identifier used by LLVM to identify pass. This allows LLVM to @@ -301,7 +301,7 @@ function.

initialization value is not important.

-  INITIALIZE_PASS(Hello, "hello", "Hello World Pass",
+  static RegisterPass X("hello", "Hello World Pass",
                         false /* Only looks at CFG */,
                         false /* Analysis Pass */);
 }  // end of anonymous namespace
@@ -328,7 +328,7 @@ is supplied as fourth argument. 

struct Hello : public FunctionPass { static char ID; - Hello() : FunctionPass(&ID) {} + Hello() : FunctionPass(ID) {} virtual bool runOnFunction(Function &F) { errs() << "Hello: " << F.getName() << "\n"; @@ -337,7 +337,7 @@ is supplied as fourth argument.

}; char Hello::ID = 0; - INITIALIZE_PASS(Hello, "Hello", "Hello World Pass", false, false); + static RegisterPass X("hello", "Hello World Pass", false, false); }
@@ -361,7 +361,7 @@ them) to be useful.

Now that you have a brand new shiny shared object file, we can use the opt command to run an LLVM program through your pass. Because you -registered your pass with the INITIALIZE_PASS macro, you will be able to +registered your pass with RegisterPass, you will be able to use the opt tool to access it, once loaded.

To test it, follow the example at the end of the Function or its contents from a pass registration works, and discussed some of the reasons that it is used and what it does. Here we discuss how and why passes are registered.

-

As we saw above, passes are registered with the INITIALIZE_PASS -macro. The first parameter is the name of the pass that is to be used on +

As we saw above, passes are registered with the RegisterPass +template. The template parameter is the name of the pass that is to be used on the command line to specify that the pass should be added to a program (for -example, with opt or bugpoint). The second argument is the +example, with opt or bugpoint). The first argument is the name of the pass, which is to be used for the -help output of programs, as well as for debug output generated by the --debug-pass option.

-- 2.11.4.GIT