X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=docs%2FWritingAnLLVMPass.html;h=07e736da691e55ae8a2aa1325e72dc0c9e2205f1;hb=26825a84e97790adaffc55c6101b9fe2524fe1b7;hp=09e5f53d6cac78c0df0a6581d5b745f7982ca57f;hpb=2397f8d0c6548e4021546ff1a58104284d79cda7;p=oota-llvm.git diff --git a/docs/WritingAnLLVMPass.html b/docs/WritingAnLLVMPass.html index 09e5f53d6ca..07e736da691 100644 --- a/docs/WritingAnLLVMPass.html +++ b/docs/WritingAnLLVMPass.html @@ -292,13 +292,19 @@ function.

initialization value is not important.

-  RegisterPass<Hello> X("hello", "Hello World Pass");
+  RegisterPass<Hello> X("hello", "Hello World Pass",
+                        false /* Only looks at CFG */,
+                        false /* Analysis Pass */);
 }  // end of anonymous namespace
 

Lastly, we register our class Hello, giving it a command line -argument "hello", and a name "Hello World Pass".

+argument "hello", and a name "Hello World Pass". +Last two RegisterPass arguments are optional. Their default value is false. +If a pass walks CFG without modifying it then third argument is set to true. +If a pass is an analysis pass, for example dominator tree pass, then true +is supplied as fourth argument.

As a whole, the .cpp file looks like:

@@ -320,6 +326,7 @@ argument "hello", and a name "Hello World Pass".

} }; + char Hello::ID = 0; RegisterPass<Hello> X("hello", "Hello World Pass"); } @@ -347,8 +354,8 @@ use the opt tool to access it, once loaded.

To test it, follow the example at the end of the Getting Started Guide to compile "Hello World" to -LLVM. We can now run the bytecode file (hello.bc) for the program -through our transformation like this (or course, any bytecode file will +LLVM. We can now run the bitcode file (hello.bc) for the program +through our transformation like this (or course, any bitcode file will work):

@@ -372,7 +379,7 @@ interesting way, we just throw away the result of opt (sending it to
 $ opt -load ../../../Debug/lib/Hello.so --help
 OVERVIEW: llvm .bc -> .bc modular optimizer
 
-USAGE: opt [options] <input bytecode>
+USAGE: opt [options] <input bitcode>
 
 OPTIONS:
   Optimizations available:
@@ -407,7 +414,7 @@ Hello: main
   Total Execution Time: 0.02 seconds (0.0479059 wall clock)
 
    ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Pass Name ---
-   0.0100 (100.0%)   0.0000 (  0.0%)   0.0100 ( 50.0%)   0.0402 ( 84.0%)  Bytecode Writer
+   0.0100 (100.0%)   0.0000 (  0.0%)   0.0100 ( 50.0%)   0.0402 ( 84.0%)  Bitcode Writer
    0.0000 (  0.0%)   0.0100 (100.0%)   0.0100 ( 50.0%)   0.0031 (  6.4%)  Dominator Set Construction
    0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0013 (  2.7%)  Module Verifier
    0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0033 (  6.9%)  Hello World Pass
@@ -995,7 +1002,7 @@ depended on.

-

One of the main responsibilities of the PassManager is the make sure +

One of the main responsibilities of the PassManager is to make sure that passes interact with each other correctly. Because PassManager tries to optimize the execution of passes it must know how the passes interact with each other and what dependencies exist between @@ -1186,7 +1193,7 @@ it is active. For example:

-

Now that we understand the basics of how passes are defined, how the are +

Now that we understand the basics of how passes are defined, how they are used, and how they are required from other passes, it's time to get a little bit fancier. All of the pass relationships that we have seen so far are very simple: one pass depends on one other specific pass to be run before it can run. @@ -1375,7 +1382,8 @@ the LLVM program representation for a single function at a time, instead of traversing the entire program. It reduces the memory consumption of compiler, because, for example, only one DominatorSet -needs to be calculated at a time. This also makes it possible some interesting enhancements in the future.

@@ -1413,8 +1421,8 @@ Module Pass Manager Module Verifier -- Dominator Set Construction -- Module Verifier - Bytecode Writer ---Bytecode Writer + Bitcode Writer +--Bitcode Writer

This output shows us when passes are constructed and when the analysis @@ -1454,8 +1462,8 @@ Module Pass Manager Module Verifier -- Dominator Set Construction -- Module Verifier - Bytecode Writer ---Bytecode Writer + Bitcode Writer +--Bitcode Writer Hello: __main Hello: puts Hello: main @@ -1494,8 +1502,8 @@ Module Pass Manager Module Verifier -- Dominator Set Construction -- Module Verifier - Bytecode Writer ---Bytecode Writer + Bitcode Writer +--Bitcode Writer Hello: __main Hello: puts Hello: main