Project Stage 2 part 5 - Final
Intro
As I mentioned in the previous post, I realized that I was doing it in a wrong way. And I saw other students progress, based on that code. I made some modifications in the pass implementation. I was looking for coped functions and their gimple representations, but I already had it printed. What I actually had to do was comparing the two different verions of one function, and then compare them, and then make a decision of whether it should be pruned or not.
Progress
This is my modified code.
unsigned int
pass_ctyler::execute (function *fun)
{
basic_block bb;
int bb_cnt = 0, stmt_cnt = 0;
FOR_EACH_BB_FN (bb, fun)
{
bb_cnt++;
if (dump_file)
{
fprintf (dump_file, "===== Basic block count: %d =====\n", bb_cnt);
if (!fun || !fun->decl)
{
fprintf(dump_file, "Invalid function object.\n");
}
else
{ // Print function name
const char *func_name = IDENTIFIER_POINTER(DECL_NAME(fun->decl));
fprintf(dump_file, "Function Name: %s\n", func_name);
}
}
for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple *g = gsi_stmt (gsi);
stmt_cnt++;
if (dump_file)
{
print_gimple_stmt (dump_file, g, 0, TDF_VOPS|TDF_MEMSYMS);
}
}
if (dump_file) {
fprintf(dump_file, "Statement Count: %d\n", stmt_cnt);
}
}
return 0;
if (dump_file)
{
fprintf (dump_file, "\n\n##### End ctyler diagnostics, start regular dump of current gimple #####\n\n\n");
}
}
}
After building it, I generated dumpfiles from clone-test-core.c file.
And then I checked, clone-test-x86-prune-clone-test-core.c.263t.ctyler file.
compared them. The two copied gimple representations were very similar.
The only differences were the variable names.
Look at those test-result1.c file and test-result2.c file, and Compare them.
You can tell that they are almost the same, and need to be pruned.
However, the problem is How we can compare them in a programmatic way.
At first, I was thinking of comparing the number of statments, but this is
too naive approach. It might work sometimes, but this is not the correct way.
Moreover, there is a bigger Challenge.
They use different variable names. This will make it impossible to compare
them as a string.
This is how much I got into this project so far. We don't have enough time
before the project due date and the end of the semester. However, I will
definitely make more effort to make further progress if a little.
Comments
Post a Comment