[LLVMdev] regarding LLVM Pass

Eli Friedman eli.friedman at gmail.com
Wed Mar 23 21:51:15 PDT 2011


On Wed, Mar 23, 2011 at 9:49 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Wed, Mar 23, 2011 at 9:15 PM, Gondi, Kalpana <kgondi2 at uic.edu> 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?
>> 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?
>>
>> 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.
>
> If you haven't looked at http://llvm.org/docs/tutorial/ , I would
> suggest taking a look; it's only partially relevant to what you're
> asking, but should give you a better feel for how stuff works.
>
>> Also, do I need to look at CLANG? How is it different from writing the
>> LLVM pass to perform the above mentioned tasks?
>
> It's different: clang has a rewriter you can use, for example, to
> insert a call after every loop.  You end up with a different
> definition of "loop", though: at the clang level, you'll see the AST
> nodes for "for" and "while" loops; at the IR level, you'll see
> constructs which are structurally loops.
>
>> Finally, did anyone compile Linux kernel using LLVM and booted the same? I
>> am facing the error like "unsupported inline asm:...".
>
> IIRC, llvm-gcc is affected by some bugs related to inline asm which
> will likely never be fixed that affect the Linux kernel (llvm-gcc is
> considered deprecated).  See
> http://llvm.org/bugs/attachment.cgi?id=3486 for building it with
> clang; the kernel tends to use all sorts of obscure/nasty gcc flags
> and constructs, which makes things tricky.

Err, make that http://llvm.org/bugs/show_bug.cgi?id=4068 ;
accidentally copy-pasted the wrong link.

-Eli




More information about the llvm-dev mailing list