Project Stage 2 part 4 - Testing clone-test-core.c file with Modified GCC file and making further modification

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' ===


#### End ctyler diagnostics, start regular dump of current gimple ####


int sum_sample (int16_t * buff, size_t samples)
{
  int x;
  int t;
  int D.3885;
  long unsigned int _1;
  long unsigned int _2;
  int16_t * _3;
  short int _4;
  int _5;
  int _10;

  <bb 2> :
  x_8 = 0;
  goto <bb 4>; [INV]

  <bb 3> :
  _1 = (long unsigned int) x_7;
  _2 = _1 * 2;
  _3 = buff_12(D) + _2;
  _4 = *_3;
  _5 = (int) _4;
  t_13 = t_6 + _5;
  x_14 = x_7 + 1;

  <bb 4> :
  # t_6 = PHI <t_9(D)(2), t_13(3)>
  # x_7 = PHI <x_8(2), x_14(3)>
  if (x_7 <= 49999999)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  _10 = t_6;

  <bb 6> :
<L3>:
  return _10;

}
This is a part of the result of clone-test-x86-prune-clone-test-core.c.263t.ctyler
dump file. The full result is available Here.

Now, we are going to further modify the pass implementation.
To do so, I need to know the cgraph_node code.
So, I read all the code in cgraph.cc file in github gcc repo

And then, I tried all the ways that I can use, to find cloned functions as follows:


unsigned int pass_ctyler::execute(function *)
{
    struct cgraph_node *node;
    struct cgraph_node *clone_node;
    int func_cnt = 0;

    FOR_EACH_FUNCTION(node)
    {
        if (dump_file)
        {
            fprintf(dump_file, "=== Function %d Name '%s' ===\n", ++func_cnt, node->name());

	    if(node->next)
	    {
		fprintf(dump_file, "node_next exists\n");
		fprintf(dump_file, "Node_Next === %s\n", node->next->name());
	    } else {
	    	fprintf(dump_file, "node->next doesn't exist\n");
	    }

	    // clone_info* info = symtab->m_clones->get(node);
	    // if(!info)
	    // {
 	    //	    fprintf(dump_file, "Info Exists\n");
	    // }

	    fprintf(dump_file, "\n=======REFERENCE DUMP============\n");

	    node->dump_references(dump_file);

	    fprintf(dump_file, "\n===================\n");

	    if(!node->clone_of) {
	    	fprintf(dump_file, "Clone_OF doesn't exsits\n");
	    } else
	    {
		fprintf(dump_file, "Clone_of exists\n");
	    }


	    if (node->next_sibling_clone) {
	    	fprintf(dump_file, "Next_Sibling_clone exists");
	    }

	    fprintf(dump_file, "\n===================\n");
	    node->dump(dump_file);
	    fprintf(dump_file, "\n======================\n");

	    // Iterate through clones if applicable
	    if(!node->clones)
	    {
		fprintf(dump_file, "Clones don't exist\n");
	    }

	    for (clone_node = (cgraph_node *)node->clones; clone_node; clone_node = (cgraph_node *)clone_node->next)
	    {
    		fprintf(dump_file, "    Clone Name: '%s'\n", clone_node->name());
	    }



        }
    }

    if (dump_file)
    {
        fprintf(dump_file, "\n\n#### End ctyler diagnostics, start regular dump of current gimple ####\n\n\n");
    }

    return 0;
}

However, I couldn't find it. I coudn't make a meaningful progress yet.


Today, I attended in the class, and saw what the classmates did.
And, I realized I completely misunderstood what I should do and change.
I think I should try to approach it very differently.
I will keep posting the following discussion in the next post.


Comments

popular posts in this blog

Project Stage 2 - part 2 : Clone-Pruning Analysis Pass

Project Stage 2 part 3 - Compile a program with revised GCC