On 2/17/2011 10:42 PM, nullnull wrote:> I'd like to run my own passes (implemented as .so) via the opt tool on
> a linked bitcode.
> >opt -load=my_own_pass.so -do_my_passes ... test.bc > test.output.bc
> However, my passes require other LLVM's passes before and after. For
> example, the ordering of passes that I want:
> (1) A couple of LLVM's passes ==> (2) my_loop_pass ==> (3)
> my_module_pass ==> (4) Other LLVM's standard O3 optimizations (a
bunch
> of passes).
> Can I enfore such complex pass ordering easily? I'd like to pass just
> a single argument in opt, which trigers the whole pipeline of passes.
In general, a pass cannot force a transform pass to always be executed
before it is run. A pass can only indicate the need for an analysis
pass via addRequired() in its getAnalysisUsage() method. This is due to
the fact that requiring some transform passes can cause create a set of
pass dependencies and pass invalidations that make the passes impossible
to schedule(*).
To do what you want, you must either:
1) Run opt and specify the transforms in the proper order.
2) Write a script that runs opt as described in 1); or
3) Write a special command-line tool that automatically schedules the
transforms to be run in the correct order
-- John T.
(*) There are a few cases in the LLVM source tree where one transform
pass successfully requires another transform pass in
getAnalysisUsage(). However, in a past conversation with PassManager's
author, I have learned that this is not supported in the general case.
> I tried to use getAnalysisUsage and addRequired. But, the
> documentation is somewhat vague, I wasn't able even to enforce the
> pass in (1) to be executed before (2) my loop pass.
> Also, I'm wondering there is a way to run other passes after my pass.
> Actually, I did it by hard coding in clang and LLVM source code. But,
> I'd like to avoid the changes in clang/LLVM as much as possible so
> that I don't need to compile LLVM suite.
> Thank you!