Not able to run pass

sir,

As defined in http://llvm.org/docs/WritingAnLLVMPass.html#setting-up-the-build-environment

running pass with opt but here how I get hello.bc file .

You can, for example, generate it with clang from some source file:

clang -emit-llvm -c hello.c -o hello.bc

Regards,
Alexander

sir,

that I already applied this.As I followed these steps:-please tell me whered did i go wrong?

  1. Checkout LLVM:
    • cd LLVM
    • svn co [http://llvm.org/svn/llvm-project/llvm/trunk](http://llvm.org/svn/llvm-project/llvm/trunk) llvm
  2. Checkout Clang:
    • cd LLVM
    • cd llvm/tools
    • svn co [http://llvm.org/svn/llvm-project/cfe/trunk](http://llvm.org/svn/llvm-project/cfe/trunk) clang
  3. Checkout Compiler-RT:
    • cd LLVM
    • cd llvm/projects
    • svn co [http://llvm.org/svn/llvm-project/compiler-rt/trunk](http://llvm.org/svn/llvm-project/compiler-rt/trunk) compiler-rt
  4. Get the Test Suite Source Code
    • cd LLVM
    • cd llvm/projects
    • svn co [http://llvm.org/svn/llvm-project/test-suite/trunk](http://llvm.org/svn/llvm-project/test-suite/trunk) test-suite
      5.Configure and build LLVM and Clang
      mkdir build (inside LLVM)
      cd build
      ../llvm/configure –prefix =/home/username/LLVM/build (path of build directory)``
      make -j4
      make check-all

attaching screenshot of errors I got

You are trying to use the pass source code to generate .bc file, it would need all the flags/includes that used to build it.
I suggest to start with something simpler for first .bc example, like:

cat > t.c
int main() { return 1+2; }

clang -emit-llvm -c t.c -o hello.bc

Regards,
Alexander

sir,

I am able to generate .bc file for other normal code but my problem how to run the pass source code. If I write some pass then how should I run that pass?

so please if you can help me in this and thanks for your reply.

The answer is right there is the documentation

$ opt -load ../../../Debug+Asserts/lib/Hello.so -hello < hello.bc > /dev/null

the ``-load`` flag loads your pass (which you built earlier) as a
plugin. Once loaded the ``-hello`` command line option becomes
available which will tell the opt tool to run that pass.

Also in future I would advise you to **not** send images of your
errors to the mailing list. It's a waste of space and you can easily
send the error messages to a file (e.g. ``clang -emit-llvm hello.cpp
2> errors.log`` ) and attach it instead which is much smaller and
easier to parse.

Thanks,
Dan.

Sir,
your answer put me in starting situation.As I told I am not able to generate .bc file of hello.cpp(the pass file) as it is giving errors when I use clang -emit-llvm -c hello.cpp -o hello.bc.So please if you can help me.

Thanks

your answer put me in starting situation.As I told I am not able to generate
.bc file of hello.cpp(the pass file) as it is giving errors when I use clang
-emit-llvm -c hello.cpp -o hello.bc.So please if you can help me.

I recently wrote a small (and rather incomplete) tutorial on LLVM
passes and provided the source code [1]. If you look in the
``helloPass`` folder you will see I've taken the helloPass from LLVM
and have built it as an out of tree plug-in. The ``run.sh`` script
(this is generated by the build system) shows how to use it. This
might help you gain understanding of how you can use the hello pass.
However I provide no guarantees that this code will work for you and I
provide absolutely no support so do not ask me questions on how to
build this code (it is already documented in README.md).

[1] https://github.com/delcypher/srg-llvm-pass-tutorial

Hi,

Thank you very much to all.