Exemplo n.º 1
0
/*
 * Frees memory at the specified pointer (that was returned by *my_malloc).
 * Also combines any free blocks that exist after the specified pointer
 * to create a larger block of free memory.
 */
void my_free(void *block) {
    int i;
    for (i = 0; i < Block.dataInfoSize; i+=INFO_BLOCK) {

        unsigned char* currentAvailablity = (Block.dataInfoPtr + i);
        int* currentSize = (Block.dataInfoPtr + i + avalaible_size);
        void** currentPtr = (Block.dataInfoPtr + i + avalaible_size + size_size);

        if (*currentPtr == block) {
            memset(block, 0, *(currentSize));
            printf("* Freed block of size %d\n", *(currentSize));
            *(currentAvailablity) = 1;
            combine_blocks();
            return;
        }
    }
    printf("* Could not find block. Returning...\n");
}
Exemplo n.º 2
0
static bool
tree_if_conversion (struct loop *loop, bool for_vectorizer)
{
  basic_block bb;
  block_stmt_iterator itr;
  unsigned int i;

  ifc_bbs = NULL;

  /* if-conversion is not appropriate for all loops. First, check if loop  is
     if-convertible or not.  */
  if (!if_convertible_loop_p (loop, for_vectorizer))
    {
      if (dump_file && (dump_flags & TDF_DETAILS))
	fprintf (dump_file,"-------------------------\n");
      if (ifc_bbs)
	{
	  free (ifc_bbs);
	  ifc_bbs = NULL;
	}
      free_dominance_info (CDI_POST_DOMINATORS);
      return false;
    }

  /* Do actual work now.  */
  for (i = 0; i < loop->num_nodes; i++)
    {
      tree cond;

      bb = ifc_bbs [i];

      /* Update condition using predicate list.  */
      cond = bb->aux;

      /* Process all statements in this basic block.
	 Remove conditional expression, if any, and annotate
	 destination basic block(s) appropriately.  */
      for (itr = bsi_start (bb); !bsi_end_p (itr); /* empty */)
	{
	  tree t = bsi_stmt (itr);
	  cond = tree_if_convert_stmt (loop, t, cond, &itr);
	  if (!bsi_end_p (itr))
	    bsi_next (&itr);
	}

      /* If current bb has only one successor, then consider it as an
	 unconditional goto.  */
      if (single_succ_p (bb))
	{
	  basic_block bb_n = single_succ (bb);
	  if (cond != NULL_TREE)
	    add_to_predicate_list (bb_n, cond);
	}
    }

  /* Now, all statements are if-converted and basic blocks are
     annotated appropriately. Combine all basic block into one huge
     basic block.  */
  combine_blocks (loop);

  /* clean up */
  clean_predicate_lists (loop);
  free (ifc_bbs);
  ifc_bbs = NULL;

  return true;
}