Commit 3944d88d by David Malcolm Committed by David Malcolm

Example of converting global state to per-pass state.

gcc/testsuite

2013-08-13  David Malcolm  <dmalcolm@redhat.com>

	Example of converting global state to per-pass state.

	* gcc.dg/plugin/one_time_plugin.c (one_pass::execute): Convert
	global state "static int counter" to...
	(one_pass::counter): ...this instance data.

From-SVN: r201681
parent b338b23f
2013-08-13 David Malcolm <dmalcolm@redhat.com> 2013-08-13 David Malcolm <dmalcolm@redhat.com>
Example of converting global state to per-pass state.
* gcc.dg/plugin/one_time_plugin.c (one_pass::execute): Convert
global state "static int counter" to...
(one_pass::counter): ...this instance data.
2013-08-13 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/plugin/one_time_plugin.c: (one_pass_gate): Convert * gcc.dg/plugin/one_time_plugin.c: (one_pass_gate): Convert
to member function... to member function...
(one_pass::gate): ...this. (one_pass::gate): ...this.
......
...@@ -33,13 +33,16 @@ class one_pass : public gimple_opt_pass ...@@ -33,13 +33,16 @@ class one_pass : public gimple_opt_pass
{ {
public: public:
one_pass(gcc::context *ctxt) one_pass(gcc::context *ctxt)
: gimple_opt_pass(pass_data_one_pass, ctxt) : gimple_opt_pass(pass_data_one_pass, ctxt),
counter(0)
{} {}
/* opt_pass methods: */ /* opt_pass methods: */
bool gate (); bool gate ();
unsigned int execute (); unsigned int execute ();
private:
int counter;
}; // class one_pass }; // class one_pass
} // anon namespace } // anon namespace
...@@ -51,8 +54,6 @@ bool one_pass::gate (void) ...@@ -51,8 +54,6 @@ bool one_pass::gate (void)
unsigned int one_pass::execute () unsigned int one_pass::execute ()
{ {
static int counter = 0;
if (counter > 0) { if (counter > 0) {
printf ("Executed more than once \n"); printf ("Executed more than once \n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment