forked from OSchip/llvm-project
				
			Document legacy pass manager extension points
Differential Revision: https://reviews.llvm.org/D64093 llvm-svn: 365142
This commit is contained in:
		
							parent
							
								
									5f73e37af8
								
							
						
					
					
						commit
						85fc597f26
					
				| 
						 | 
					@ -45,6 +45,10 @@ Non-comprehensive list of changes in this release
 | 
				
			||||||
  the platform's libc) without specifying ``-ffreestanding`` may need to either
 | 
					  the platform's libc) without specifying ``-ffreestanding`` may need to either
 | 
				
			||||||
  pass ``-fno-builtin-bcmp``, or provide a ``bcmp`` function.
 | 
					  pass ``-fno-builtin-bcmp``, or provide a ``bcmp`` function.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* Two new extension points, namely ``EP_FullLinkTimeOptimizationEarly`` and
 | 
				
			||||||
 | 
					  ``EP_FullLinkTimeOptimizationLast`` are available for plugins to specialize
 | 
				
			||||||
 | 
					  the legacy pass manager full LTO pipeline.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. NOTE
 | 
					.. NOTE
 | 
				
			||||||
   If you would like to document a larger change, then you can add a
 | 
					   If you would like to document a larger change, then you can add a
 | 
				
			||||||
   subsection about it right here. You can copy the following boilerplate
 | 
					   subsection about it right here. You can copy the following boilerplate
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -178,6 +178,18 @@ without modifying it then the third argument is set to ``true``; if a pass is
 | 
				
			||||||
an analysis pass, for example dominator tree pass, then ``true`` is supplied as
 | 
					an analysis pass, for example dominator tree pass, then ``true`` is supplied as
 | 
				
			||||||
the fourth argument.
 | 
					the fourth argument.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If we want to register the pass as a step of an existing pipeline, some extension
 | 
				
			||||||
 | 
					points are provided, e.g. ``PassManagerBuilder::EP_EarlyAsPossible`` to apply our
 | 
				
			||||||
 | 
					pass before any optimization, or ``PassManagerBuilder::EP_FullLinkTimeOptimizationLast``
 | 
				
			||||||
 | 
					to apply it after Link Time Optimizations.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. code-block:: c++
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static llvm::RegisterStandardPasses Y(
 | 
				
			||||||
 | 
					        llvm::PassManagerBuilder::EP_EarlyAsPossible,
 | 
				
			||||||
 | 
					        [](const llvm::PassManagerBuilder &Builder,
 | 
				
			||||||
 | 
					           llvm::legacy::PassManagerBase &PM) { PM.add(new Hello()); });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
As a whole, the ``.cpp`` file looks like:
 | 
					As a whole, the ``.cpp`` file looks like:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. code-block:: c++
 | 
					.. code-block:: c++
 | 
				
			||||||
| 
						 | 
					@ -186,6 +198,9 @@ As a whole, the ``.cpp`` file looks like:
 | 
				
			||||||
  #include "llvm/IR/Function.h"
 | 
					  #include "llvm/IR/Function.h"
 | 
				
			||||||
  #include "llvm/Support/raw_ostream.h"
 | 
					  #include "llvm/Support/raw_ostream.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  #include "llvm/IR/LegacyPassManager.h"
 | 
				
			||||||
 | 
					  #include "llvm/Transforms/IPO/PassManagerBuilder.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  using namespace llvm;
 | 
					  using namespace llvm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  namespace {
 | 
					  namespace {
 | 
				
			||||||
| 
						 | 
					@ -206,6 +221,11 @@ As a whole, the ``.cpp`` file looks like:
 | 
				
			||||||
                               false /* Only looks at CFG */,
 | 
					                               false /* Only looks at CFG */,
 | 
				
			||||||
                               false /* Analysis Pass */);
 | 
					                               false /* Analysis Pass */);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static RegisterStandardPasses Y(
 | 
				
			||||||
 | 
					      PassManagerBuilder::EP_EarlyAsPossible,
 | 
				
			||||||
 | 
					      [](const PassManagerBuilder &Builder,
 | 
				
			||||||
 | 
					         legacy::PassManagerBase &PM) { PM.add(new Hello()); });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Now that it's all together, compile the file with a simple "``gmake``" command
 | 
					Now that it's all together, compile the file with a simple "``gmake``" command
 | 
				
			||||||
from the top level of your build directory and you should get a new file
 | 
					from the top level of your build directory and you should get a new file
 | 
				
			||||||
"``lib/LLVMHello.so``".  Note that everything in this file is
 | 
					"``lib/LLVMHello.so``".  Note that everything in this file is
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue