I want to make a pass that changing control flow.
The pass should change the if condition.
Let's assume the original code is like below.
int main(int argc, char *argv[])
{
if (atoi(argv[1]) % 2 == 0)
printf("even\n");
else
printf("odd\n");
return 0;
}
After apply my pass the code should be changed to below. (Not mean that changing the source code, but IR code in real.)
int main(int argc, char *argv[])
{
if (atoi(argv[1]) % 2 == 1) //the condition of if statement is changed to 1
printf("even\n");
else
printf("odd\n");
return 0;
}
this is just a toy example of what I really want to do but I have difficulties about
- finding appropriate instructions want to change
- and changing the control flows.