[LLVMdev] Function permutation at IR bytecode level

John Criswell criswell at illinois.edu
Fri Mar 8 08:36:40 PST 2013


On 3/7/13 5:38 PM, teja tamboli wrote:
> Hi All,
>
> I am working on writing pass in LLVM and interested in doing function 
> permutation at intermediate representation byte code level?
>
> If I have lets say C program having three functions and its 
> corresponding IR bytecode.
>
> void findLen(char a[10])
> {
>    int tmp = strlen(a);
>    printf("Len is : %d\n", tmp);
> }
> void muladd(int a, int b, int c)
> {
>    int tmp = a + b;
>    int tmp1 = tmp * c;
>    printf("Addition is : %d Multiplication is : %d\n", tmp, tmp1);
>    char d[10] =  "abhd";
>    findLen(d);
> }
> void main()
> {
>    int x = 8, y = 5, z = 3;
>    muladd(x, y, z);
> }
>
> In its corresponding .s [IR bytecode] file function sequence will be 
> same first findLen() then muladd() and then main().
> Suppose I want to change this sequence i.e. swap findLen() and 
> muladd() function's positions. I am expecting to have IR bytecode of 
> first muladd() then findLen() and then main() in the output file.
>
> Can you please tell me how can I achieve it ?

Have you tried changing the order in which the Functions are inserted 
into the Module?  That might work if the code generator generates 
functions in the order in which they appear in the Module.

-- John T.

>
> Thanks,
> Teja
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

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


More information about the llvm-dev mailing list