[LLVMdev] regarding LLVM Pass
John Criswell
criswell at cs.uiuc.edu
Wed Mar 23 21:58:31 PDT 2011
On 3/23/11 11:15 PM, Gondi, Kalpana wrote:
> Hi All,
> I am a newbie to LLVM and I would like to write an LLVM pass where I can
> transform C code. Say, I would like to introduce a print statement after
> every loop. Could you please provide me any hints as how I should proceed
> to write such transformation using LLVM?
You essentially want to create a call instruction to printf. Look for
the doxygen documentation on the llvm.org web site and look for the
llvm::CallInst class. The Create() method of CallInst is what you want
to use.
> Also, I would like to analyze C Code and transform. Say, I would like to
> use Alias analysis and decide to introduce print statements for some
> pointer variables inside the code itself. Any suggestion as where I should
> start?
Try to find examples that use the AliasAnalysis interface. The
interface itself should be defined in a header file; it should be pretty
easy to use, although the underlying implementation is still pretty
simple, as far as I know.
> I've been going through documentation like, writing an LLVM Pass , but I
> guess, I need much more exposure than just going through such
> documentation.
>
> Also, do I need to look at CLANG? How is it different from writing the
> LLVM pass to perform the above mentioned tasks?
Clang is useful for working with source-level ASTs.
> Finally, did anyone compile Linux kernel using LLVM and booted the same? I
> am facing the error like "unsupported inline asm:...".
Yes and no, depending on one's perspective. I ported Linux 2.4 to a
virtual architecture, meaning that I ripped out all the inline asm code
and replaced it with calls to my VM which implemented it own assembly
code. The C code parts of the kernel were compiled with LLVM.
I think other people have compiled Linux 2.6 out-of-the-box (or pretty
close to it) with newer versions of LLVM. I'll let them comment.
-- John T.
> Please help me with all these. And I appreciate your support and patience.
>
> Thanks,
> GK
>
>
>
> _______________________________________________
> 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