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

(-)gcc/sanopt.c.jj (-5 / +30 lines)
Lines 662-681 const pass_data pass_data_sanopt = Link Here
662
  0, /* properties_provided */
662
  0, /* properties_provided */
663
  0, /* properties_destroyed */
663
  0, /* properties_destroyed */
664
  0, /* todo_flags_start */
664
  0, /* todo_flags_start */
665
  TODO_update_ssa, /* todo_flags_finish */
665
  0, /* todo_flags_finish */
666
};
666
};
667
667
668
class pass_sanopt : public gimple_opt_pass
668
class pass_sanopt : public gimple_opt_pass
669
{
669
{
670
public:
670
public:
671
  pass_sanopt (gcc::context *ctxt)
671
  pass_sanopt (gcc::context *ctxt)
672
    : gimple_opt_pass (pass_data_sanopt, ctxt)
672
    : gimple_opt_pass (pass_data_sanopt, ctxt),
673
      lower_p (false)
673
  {}
674
  {}
674
675
675
  /* opt_pass methods: */
676
  /* opt_pass methods: */
676
  virtual bool gate (function *) { return flag_sanitize; }
677
  opt_pass * clone () { return new pass_sanopt (m_ctxt); }
678
  void set_pass_param (unsigned int n, bool param)
679
    {
680
      gcc_assert (n == 0);
681
      lower_p = param;
682
    }
683
  virtual bool gate (function *)
684
    {
685
      if (!lower_p)
686
	return (flag_sanitize
687
		& (SANITIZE_NULL | SANITIZE_ALIGNMENT
688
		   | SANITIZE_ADDRESS | SANITIZE_VPTR));
689
      return flag_sanitize;
690
    }
677
  virtual unsigned int execute (function *);
691
  virtual unsigned int execute (function *);
678
692
693
private:
694
  /* True if the pass shouldn't do just optimizations (removing
695
     redundancies), but also lowering of internal fns.  That should
696
     be done just once, in the last instance of the pass.  */
697
  bool lower_p;
679
}; // class pass_sanopt
698
}; // class pass_sanopt
680
699
681
/* Sanitize all ASAN_MARK unpoison calls that are not reachable by a BB
700
/* Sanitize all ASAN_MARK unpoison calls that are not reachable by a BB
Lines 870-876 pass_sanopt::execute (function *fun) Link Here
870
      && (flag_sanitize
889
      && (flag_sanitize
871
	  & (SANITIZE_NULL | SANITIZE_ALIGNMENT
890
	  & (SANITIZE_NULL | SANITIZE_ALIGNMENT
872
	     | SANITIZE_ADDRESS | SANITIZE_VPTR)))
891
	     | SANITIZE_ADDRESS | SANITIZE_VPTR)))
873
    asan_num_accesses = sanopt_optimize (fun, &contains_asan_mark);
892
    {
893
      asan_num_accesses = sanopt_optimize (fun, &contains_asan_mark);
894
      if (!lower_p)
895
	return 0;
896
    }
897
  else if (!lower_p)
898
    return 0;
874
  else if (flag_sanitize & SANITIZE_ADDRESS)
899
  else if (flag_sanitize & SANITIZE_ADDRESS)
875
    {
900
    {
876
      gimple_stmt_iterator gsi;
901
      gimple_stmt_iterator gsi;
Lines 973-979 pass_sanopt::execute (function *fun) Link Here
973
  if (need_commit_edge_insert)
998
  if (need_commit_edge_insert)
974
    gsi_commit_edge_inserts ();
999
    gsi_commit_edge_inserts ();
975
1000
976
  return 0;
1001
  return TODO_update_ssa;
977
}
1002
}
978
1003
979
} // anon namespace
1004
} // anon namespace
(-)gcc/passes.def.jj (-1 / +2 lines)
Lines 191-196 along with GCC; see the file COPYING3. Link Here
191
      /* Initial scalar cleanups before alias computation.
191
      /* Initial scalar cleanups before alias computation.
192
	 They ensure memory accesses are not indirect wherever possible.  */
192
	 They ensure memory accesses are not indirect wherever possible.  */
193
      NEXT_PASS (pass_strip_predict_hints);
193
      NEXT_PASS (pass_strip_predict_hints);
194
      NEXT_PASS (pass_sanopt, false /* lower_p */);
194
      NEXT_PASS (pass_ccp, true /* nonzero_p */);
195
      NEXT_PASS (pass_ccp, true /* nonzero_p */);
195
      NEXT_PASS (pass_post_ipa_warn);
196
      NEXT_PASS (pass_post_ipa_warn);
196
      /* After CCP we rewrite no longer addressed locals into SSA
197
      /* After CCP we rewrite no longer addressed locals into SSA
Lines 396-402 along with GCC; see the file COPYING3. Link Here
396
  NEXT_PASS (pass_sancov_O0);
397
  NEXT_PASS (pass_sancov_O0);
397
  NEXT_PASS (pass_asan_O0);
398
  NEXT_PASS (pass_asan_O0);
398
  NEXT_PASS (pass_tsan_O0);
399
  NEXT_PASS (pass_tsan_O0);
399
  NEXT_PASS (pass_sanopt);
400
  NEXT_PASS (pass_sanopt, true /* lower_p */);
400
  NEXT_PASS (pass_cleanup_eh);
401
  NEXT_PASS (pass_cleanup_eh);
401
  NEXT_PASS (pass_lower_resx);
402
  NEXT_PASS (pass_lower_resx);
402
  NEXT_PASS (pass_nrv);
403
  NEXT_PASS (pass_nrv);

Return to bug 83356