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)
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 = “abhd”;
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 ?