Why llvm-pass don't work when applied on itself(passfile)

Hi,
I applied some pass i.e. Hello pass on Hello.cpp(the pass file).It doesnot work as using command clang -emit-llvm -c Hello.c(Hell.cpp) does not create any .bc file .Can any body have some suggestion ?

Is the problem that you can’t create a bitcode file or that you can’t get clang to run your pass? Assuming you can’t generate a bitcode file, clang -emit-llvm -c <file.c> should create a file ending with .o that is an LLVM bitcode file. It will not have a .bc suffix. Regards, John Criswell

Let’s take Hello.cpp pass file from llvm/lib/Transform/Hello. Now I want to run clang -emit-llvm -c Hello.cpp(Hello.c).Means I want to apply this pass on itself.Then there are too many errors.

You need to be more specific about how you are running your pass on the bitcode file and what errors you are seeing. No one can figure out what the problem is with the small amount of information that you have provided. Regards, John Criswell

Sir,

I have attached the full procedure I have followed.may be this would help you to understand my problem

steps.txt (1.41 KB)

The problem is that you’re not specifying all the -I options needed to tell clang where to find the LLVM header files that Hello.cpp is using. Here’s what you should do: 1) Go to the place where Hello.cpp is and do a make clean 2) Rebuild Hello.so, but use make VERBOSE=1 to get make to print out the commands it is running to build Hello.o and Hello.so 3) Take those commands and replace gcc with clang and add the -emit-llvm option. For example, in an old LLVM 3.2 sample project, make VERBOSE=1 generates the following output: clang -I/Users/criswell/box/x86/llvm32/include -I/Users/criswell/box/x86/llvm32/projects/sample/include -I/Users/criswell/box/x86/llvm32/projects/sample/lib/sample -I/Users/criswell/src/llvm32/include -I/Users/criswell/src/llvm32/projects/sample/include -I/Users/criswell/src/llvm32/projects/sample/lib/sample -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fno-common -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c -MMD -MP -MF “/Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.d.tmp” -MT “/Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.o” -MT “/Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.d” /Users/criswell/src/llvm32/projects/sample/lib/sample/sample.c -o /Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.o Since make is already using clang to compile the code, I don’t need to change that. However, I need to add -emit-llvm to make sample.o a bitcode file: clang -emit-llvm -I/Users/criswell/box/x86/llvm32/include -I/Users/criswell/box/x86/llvm32/projects/sample/include -I/Users/criswell/box/x86/llvm32/projects/sample/lib/sample -I/Users/criswell/src/llvm32/include -I/Users/criswell/src/llvm32/projects/sample/include -I/Users/criswell/src/llvm32/projects/sample/lib/sample -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fno-common -m64 -pedantic -Wno-long-long -Wall -W -Wno-unused-parameter -Wwrite-strings -c -MMD -MP -MF “/Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.d.tmp” -MT “/Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.o” -MT “/Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.d” /Users/criswell/src/llvm32/projects/sample/lib/sample/sample.c -o /Users/criswell/box/x86/llvm32/projects/sample/lib/sample/Release+Asserts/sample.o Regards, John Criswell