Intro This post will wrap up the project for SPO600 course. As a reminder; the goal of this project was to modify GCC Compiler to check if a cloned function can be pruned or not. However, I couldn't achieve the goal. Instead, I made a few small progresses. In this post, I will explain and wrap up the progresses that I made so far. Progress I made a few more changes from Stage 2. Actually this version is made by combining different versions of the pass implementations that I have made during this project. So it's not a huge progress: unsigned int pass_ctyler::execute(function *) { struct cgraph_node *node; int func_cnt = 0; int *stmt_counts = (int *)xmalloc(30 * sizeof(int)); FOR_EACH_FUNCTION(node) { int stmt_cnt = 0; if (dump_file) { if (node) { fprintf(dump_file, "Function Name === %s\n", node->name()); function *fn = node->get_fun(); if (fn) { ...
Intro In Project Stage 2, we are going to add a Pass to gcc compiler. Then, we will compile a code and see it generates a dump file that we added a pass for. Progress Let's start with adding a Pass to GCC compiler. 1. Open passes.def file in ~/project/gcc/gcc folder vi passes.def 2. You will See the codes as followings. Then, add a pass NEXT_PASS (pass_ctyler); in line 444 440 NEXT_PASS (pass_cleanup_eh); 441 NEXT_PASS (pass_musttail); 442 NEXT_PASS (pass_lower_resx); 443 NEXT_PASS (pass_nrv); 444 NEXT_PASS (pass_ctyler); # Add your pass here # If you change the location, the order of compilation is changed; and it might have problem. # Since `pass_ctyler` is similar to `pass_nrv` I think it's safe to put here 445 NEXT_PASS (pass_gimple_isel); 446 NEXT_PASS (pass_harden_conditional_branches); 447 NEXT_PASS (pass_harden_compares); 448 NEXT_PASS (pass_warn_access, /*early=*/false); ...
Intro In the previous post, we modified to make it print function names; Now, we are going to test it with given clone-test-core.c file and also we will try to make further changes to display more information such as cloned function and gimple representation. Progress First, I tested the provided code without making any modifications, and the results are as follows: ;; Function sum_sample (sum_sample, funcdef_no=6, decl_uid=3859, cgraph_uid=7, symbol_order=6) === Function 1 Name '__builtin_cpu_supports' === === Function 2 Name '__builtin_cpu_init' === === Function 3 Name 'scale_samples.resolver' === === Function 4 Name 'scale_samples' === === Function 5 Name 'scale_samples.popcnt' === === Function 6 Name 'printf' === === Function 7 Name 'vol_createsample' === === Function 8 Name 'calloc' === === Function 9 Name 'main' === === Function 10 Name 'scale_samples' === === Function 11 Name 'sum_sample' =...
Comments
Post a Comment