[LLVMdev] Performing my own pass with a single command line?
John Criswell
criswell at uiuc.edu
Mon Apr 19 07:11:59 PDT 2010
Dear Zheng Wang,
You have a few options:
1) You can add your pass to the set of passes that llvm-gcc runs when it
optimizes code. This requires re-compiling llvm-gcc; it also means that
your pass must be able to run on incomplete programs and be run multiple
times over the same code (i.e., it cannot do whole-program analysis).
2) You can change the build system of the program you're working with to
generate an LLVM bitcode file. It's the same as what you're doing now,
except that the program's Makefiles automate the task for you.
3) You can add your passes to libLTO
(http://llvm.org/docs/GoldPlugin.html and
http://llvm.org/docs/LinkTimeOptimization.html). This will allow your
passes to be run at link-time by the linker. This method takes some
time to set up, but it should work beautfully once set up. Furthermore,
it can do whole-program analysis and optimization (the linker knows when
it is creating a final executable vs. an object file and can defer whole
program analysis and transformation until the final link stage).
-- John T.
Zheng Wang wrote:
> Hello,
>
>
> As far as I know, the LLVM pass manager only perform at the llvm
> bytecode level.
>
> This means for each program, I have to convert it to a LLVM bytecode by:
>
> llvm-gcc -c -emit-llvm test.c
>
> then, I can issue the llvm pass manager to invoke my own pass and
> produce an output as LLVM bytecode, such as:
>
> opt -my-pass < test.o > test.new.o
>
> After this point, I need to convert it to assembly code using llc,
> then to use 'as' to compile the assembly code to an object file, and
> finally I can
> use gcc to generate an executable program.
>
> *****My question is*****, is there any way to automatically evoke the
> pass manager, such as:
>
> llvm-gcc -c test.c
>
> and in such a way my own pass will be evoked?
>
> Cheers,
> Zheng
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list