[LLVMdev] Question about writing a pass

Zhang Qiuyu qiuyu at ucla.edu
Sat Dec 4 01:13:18 PST 2004

Hi ,

I got a few for writing a pass.

1) Is it possible to use input parameters in command line ?
    For example, we got our own pass, ie. HELLO
    opt -load ../../Debug/lib/libHELLO.so -HELLO < hello.bc
    From the above command line, could we use some input parameter and we can read those parameter in Pass routine?

2) For splitting BB, the way what I did is to pick up instruction randomly and do splitting before this instruction. But sometime I got error when I run the Pass. It seems some of instruction set cannot be splitted, right? the instruction like 'phi..'. If so, how could we check this instruction to see if it can be splitted or not.

3) Here is a piece of code

  char a[]="hello world";
  int i;


And I got IR code like the following

no_exit:  ; preds = %strlen.entry, %no_exit

 %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %strlen.entry ]  ; <uint> [#uses=3]
 %i.0.0 = cast uint %indvar to int  ; <int> [#uses=1]
 %tmp.24 = getelementptr [12 x sbyte]* %a, int 0, uint %indvar  ; <sbyte*> [#uses=2]
 %tmp.28 = load sbyte* %tmp.24  ; <sbyte> [#uses=1]
 %tmp.29 = add sbyte %tmp.28, 1  ; <sbyte> [#uses=1]
 store sbyte %tmp.29, sbyte* %tmp.24
 %inc = add int %i.0.0, 1  ; <int> [#uses=1]
 %tmp.20 = setlt int %inc, %tmp.17  ; <bool> [#uses=1]
 %indvar.next = add uint %indvar, 1  ; <uint> [#uses=1]
 br bool %tmp.20, label %no_exit, label %loopexit

So does it mean that I should insert all the IR code if I would like to insert a for loop in existed code. I can do it by inserting a call funcation. Here, I need insert for loop into the code body.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20041204/79ef4580/attachment.html>

More information about the llvm-dev mailing list