View | Details | Return to bug 56490
Collapse All | Expand All

(-)gcc/params.def.jj (+6 lines)
Lines 1078-1083 DEFPARAM (PARAM_ASAN_USE_AFTER_RETURN, Link Here
1078
         "asan-use-after-return",
1078
         "asan-use-after-return",
1079
         "Enable asan builtin functions protection",
1079
         "Enable asan builtin functions protection",
1080
         1, 0, 1)
1080
         1, 0, 1)
1081
1082
DEFPARAM (PARAM_UNINIT_CONTROL_DEP_ATTEMPTS,
1083
	  "uninit-control-dep-attempts",
1084
	  "Maximum number of nested calls to search for control dependencies "
1085
	  "during uninitialized variable analysis",
1086
	  1000, 1, 0)
1081
/*
1087
/*
1082
1088
1083
Local variables:
1089
Local variables:
(-)gcc/tree-ssa-uninit.c.jj (-40 / +25 lines)
Lines 44-49 along with GCC; see the file COPYING3. Link Here
44
#include "hashtab.h"
44
#include "hashtab.h"
45
#include "tree-pass.h"
45
#include "tree-pass.h"
46
#include "diagnostic-core.h"
46
#include "diagnostic-core.h"
47
#include "params.h"
47
48
48
/* This implements the pass that does predicate aware warning on uses of
49
/* This implements the pass that does predicate aware warning on uses of
49
   possibly uninitialized variables. The pass first collects the set of
50
   possibly uninitialized variables. The pass first collects the set of
Lines 390-397 find_control_equiv_block (basic_block bb Link Here
390
391
391
/* Computes the control dependence chains (paths of edges)
392
/* Computes the control dependence chains (paths of edges)
392
   for DEP_BB up to the dominating basic block BB (the head node of a
393
   for DEP_BB up to the dominating basic block BB (the head node of a
393
   chain should be dominated by it).  CD_CHAINS is pointer to a
394
   chain should be dominated by it).  CD_CHAINS is pointer to an
394
   dynamic array holding the result chains. CUR_CD_CHAIN is the current
395
   array holding the result chains.  CUR_CD_CHAIN is the current
395
   chain being computed.  *NUM_CHAINS is total number of chains.  The
396
   chain being computed.  *NUM_CHAINS is total number of chains.  The
396
   function returns true if the information is successfully computed,
397
   function returns true if the information is successfully computed,
397
   return false if there is no control dependence or not computed.  */
398
   return false if there is no control dependence or not computed.  */
Lines 400-406 static bool Link Here
400
compute_control_dep_chain (basic_block bb, basic_block dep_bb,
401
compute_control_dep_chain (basic_block bb, basic_block dep_bb,
401
                           vec<edge> *cd_chains,
402
                           vec<edge> *cd_chains,
402
                           size_t *num_chains,
403
                           size_t *num_chains,
403
                           vec<edge> *cur_cd_chain)
404
			   vec<edge> *cur_cd_chain,
405
			   size_t *num_calls)
404
{
406
{
405
  edge_iterator ei;
407
  edge_iterator ei;
406
  edge e;
408
  edge e;
Lines 411-416 compute_control_dep_chain (basic_block b Link Here
411
  if (EDGE_COUNT (bb->succs) < 2)
413
  if (EDGE_COUNT (bb->succs) < 2)
412
    return false;
414
    return false;
413
415
416
  if (*num_calls > PARAM_VALUE (PARAM_UNINIT_CONTROL_DEP_ATTEMPTS))
417
    return false;
418
  ++*num_calls;
419
414
  /* Could use a set instead.  */
420
  /* Could use a set instead.  */
415
  cur_chain_len = cur_cd_chain->length ();
421
  cur_chain_len = cur_cd_chain->length ();
416
  if (cur_chain_len > MAX_CHAIN_LEN)
422
  if (cur_chain_len > MAX_CHAIN_LEN)
Lines 450-456 compute_control_dep_chain (basic_block b Link Here
450
456
451
          /* Now check if DEP_BB is indirectly control dependent on BB.  */
457
          /* Now check if DEP_BB is indirectly control dependent on BB.  */
452
          if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains,
458
          if (compute_control_dep_chain (cd_bb, dep_bb, cd_chains,
453
                                         num_chains, cur_cd_chain))
459
					 num_chains, cur_cd_chain, num_calls))
454
            {
460
            {
455
              found_cd_chain = true;
461
              found_cd_chain = true;
456
              break;
462
              break;
Lines 594-608 find_predicates (pred_chain_union *preds Link Here
594
                 basic_block phi_bb,
600
                 basic_block phi_bb,
595
                 basic_block use_bb)
601
                 basic_block use_bb)
596
{
602
{
597
  size_t num_chains = 0, i;
603
  size_t num_chains = 0, i, num_calls = 0;
598
  vec<edge> *dep_chains = 0;
604
  vec<edge> dep_chains[MAX_NUM_CHAINS];
599
  vec<edge> cur_chain = vNULL;
605
  auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
600
  bool has_valid_pred = false;
606
  bool has_valid_pred = false;
601
  basic_block cd_root = 0;
607
  basic_block cd_root = 0;
602
608
603
  typedef vec<edge> vec_edge_heap;
604
  dep_chains = XCNEWVEC (vec_edge_heap, MAX_NUM_CHAINS);
605
606
  /* First find the closest bb that is control equivalent to PHI_BB
609
  /* First find the closest bb that is control equivalent to PHI_BB
607
     that also dominates USE_BB.  */
610
     that also dominates USE_BB.  */
608
  cd_root = phi_bb;
611
  cd_root = phi_bb;
Lines 615-633 find_predicates (pred_chain_union *preds Link Here
615
        break;
618
        break;
616
    }
619
    }
617
620
618
  compute_control_dep_chain (cd_root, use_bb,
621
  compute_control_dep_chain (cd_root, use_bb, dep_chains, &num_chains,
619
                             dep_chains, &num_chains,
622
			     &cur_chain, &num_calls);
620
                             &cur_chain);
621
623
622
  has_valid_pred
624
  has_valid_pred
623
      = convert_control_dep_chain_into_preds (dep_chains,
625
    = convert_control_dep_chain_into_preds (dep_chains, num_chains, preds);
624
                                              num_chains,
625
                                              preds);
626
  /* Free individual chain  */
627
  cur_chain.release ();
628
  for (i = 0; i < num_chains; i++)
626
  for (i = 0; i < num_chains; i++)
629
    dep_chains[i].release ();
627
    dep_chains[i].release ();
630
  free (dep_chains);
631
  return has_valid_pred;
628
  return has_valid_pred;
632
}
629
}
633
630
Lines 694-709 static bool Link Here
694
find_def_preds (pred_chain_union *preds, gimple phi)
691
find_def_preds (pred_chain_union *preds, gimple phi)
695
{
692
{
696
  size_t num_chains = 0, i, n;
693
  size_t num_chains = 0, i, n;
697
  vec<edge> *dep_chains = 0;
694
  vec<edge> dep_chains[MAX_NUM_CHAINS];
698
  vec<edge> cur_chain = vNULL;
695
  auto_vec<edge, MAX_CHAIN_LEN + 1> cur_chain;
699
  vec<edge> def_edges = vNULL;
696
  vec<edge> def_edges = vNULL;
700
  bool has_valid_pred = false;
697
  bool has_valid_pred = false;
701
  basic_block phi_bb, cd_root = 0;
698
  basic_block phi_bb, cd_root = 0;
702
  pointer_set_t *visited_phis;
699
  pointer_set_t *visited_phis;
703
700
704
  typedef vec<edge> vec_edge_heap;
705
  dep_chains = XCNEWVEC (vec_edge_heap, MAX_NUM_CHAINS);
706
707
  phi_bb = gimple_bb (phi);
701
  phi_bb = gimple_bb (phi);
708
  /* First find the closest dominating bb to be
702
  /* First find the closest dominating bb to be
709
     the control dependence root  */
703
     the control dependence root  */
Lines 721-758 find_def_preds (pred_chain_union *preds, Link Here
721
715
722
  for (i = 0; i < n; i++)
716
  for (i = 0; i < n; i++)
723
    {
717
    {
724
      size_t prev_nc, j;
718
      size_t prev_nc, j, num_calls = 0;
725
      edge opnd_edge;
719
      edge opnd_edge;
726
720
727
      opnd_edge = def_edges[i];
721
      opnd_edge = def_edges[i];
728
      prev_nc = num_chains;
722
      prev_nc = num_chains;
729
      compute_control_dep_chain (cd_root, opnd_edge->src,
723
      compute_control_dep_chain (cd_root, opnd_edge->src, dep_chains,
730
                                 dep_chains, &num_chains,
724
				 &num_chains, &cur_chain, &num_calls);
731
                                 &cur_chain);
732
      /* Free individual chain  */
733
      cur_chain.release ();
734
725
735
      /* Now update the newly added chains with
726
      /* Now update the newly added chains with
736
         the phi operand edge:  */
727
         the phi operand edge:  */
737
      if (EDGE_COUNT (opnd_edge->src->succs) > 1)
728
      if (EDGE_COUNT (opnd_edge->src->succs) > 1)
738
        {
729
        {
739
          if (prev_nc == num_chains
730
	  if (prev_nc == num_chains && num_chains < MAX_NUM_CHAINS)
740
              && num_chains < MAX_NUM_CHAINS)
731
	    dep_chains[num_chains++] = vNULL;
741
            num_chains++;
742
          for (j = prev_nc; j < num_chains; j++)
732
          for (j = prev_nc; j < num_chains; j++)
743
            {
733
	    dep_chains[j].safe_push (opnd_edge);
744
              dep_chains[j].safe_push (opnd_edge);
745
            }
746
        }
734
        }
747
    }
735
    }
748
736
749
  has_valid_pred
737
  has_valid_pred
750
      = convert_control_dep_chain_into_preds (dep_chains,
738
    = convert_control_dep_chain_into_preds (dep_chains, num_chains, preds);
751
                                              num_chains,
752
                                              preds);
753
  for (i = 0; i < num_chains; i++)
739
  for (i = 0; i < num_chains; i++)
754
    dep_chains[i].release ();
740
    dep_chains[i].release ();
755
  free (dep_chains);
756
  return has_valid_pred;
741
  return has_valid_pred;
757
}
742
}
758
743

Return to bug 56490