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

John Criswell criswell at illinois.edu
Mon Jun 16 12:47:33 PDT 2014


On 6/16/14, 2:41 PM, Prashanth Sharma wrote:
> Sir,
> I have attached the full procedure I have followed.may be this would 
> help you to understand my problem

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

>
>
> On Mon, Jun 16, 2014 at 12:17 AM, John Criswell <criswell at illinois.edu 
> <mailto:criswell at illinois.edu>> wrote:
>
>     On 6/15/14, 12:04 PM, Prashanth Sharma wrote:
>>     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
>
>
>>
>>
>>     On Sun, Jun 15, 2014 at 10:27 PM, John Criswell
>>     <criswell at illinois.edu <mailto:criswell at illinois.edu>> wrote:
>>
>>         On 6/14/14, 6:02 AM, Prashanth Sharma wrote:
>>>         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
>>
>>
>>>
>>>         -- 
>>>         Thanks
>>>         Prashant Sharma
>>>
>>>
>>>         _______________________________________________
>>>         LLVM Developers mailing list
>>>         LLVMdev at cs.uiuc.edu  <mailto:LLVMdev at cs.uiuc.edu>          http://llvm.cs.uiuc.edu
>>>         http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>
>>
>>
>>
>>     -- 
>>     Thanks
>>     Prashant Sharma
>
>
>
>
> -- 
> Thanks
> Prashant Sharma

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140616/8c15373f/attachment.html>


More information about the llvm-dev mailing list