10.05.2013, 22:54, "John Regehr" <[email protected]>:
> Konstantin, we will be getting back to do some more active C-Reduce
> development soon.  Are there any particular passes that you've noticed
> are missing?

1. There should be a pass transforming class method into stand-alone function 
(at least if it does not access fields and other methods). Resulting test cases 
often contain classes without fields where only methods are interesting.

I've started to work on transformation of class into namespace (methods become 
namespace functions, fields become namespace variables, method invocations 
become calls of namespace functions, etc.), but later come to conclusion that 
tranformation is too large and is too likely to fail.

2. pass_peep :: b is very slow, and when it's running on 60k-sized test cases 
it's not exciting at all, so I found convenient to comment it out while 
reducing, than enable back when reduction finishes and run again. I've checked 
what it typixally does for C++ code and found the next passes could partially 
replace it:

* eleminate const qualifiers from methods (pass_peep actually cannot get it if 
method has out-of-line definition)
* remove explicit from constructors
* remove name of enum if this name is not used as a type
* remove attributes of all kinds
* remove unused parameter names everywhere
* remove arguments from ellipsis functions, or functions with default values, 
or template instantiations with default values.
* transform references into values
* transform classes into structs with removed access specifiers and friend 
declarations (let me take this one for now)

Also, pass_peep :: b itself might have a room for optimizations (it utilizes 
100% of CPU for a while without running predicate)

3. Transform enum-type parameters into int, than remove enum if it is empty and 
not used as a type anywhere
4. Collapse identical class/struct declarations into one declaration

Also, I've written pass substitute-class-template-param replacing template 
parameter inside template definition with instantiation argument when only one 
is used. It already proven itself to be effective for reducing 
heavily-templated code, but should probably be extended to hadle more cases. 
Also, it sometimes produces incompilable code when inserted argument requires 
forward declaration. Should the pass add it every time (leading to test case 
bloating if unneeded), or it should be another pass?

Another thought is that writing passes requires too much boilerplate code now. 
AFAIU, simple transformation consists of the next steps:
1. Traverse AST checking nodes of type X for compliance with predicate A
2. Each time node matches increment counter and check if we reached 
TransformationCounter value). If so, save node in TheX variable. (To be faster, 
we should also return false to stop traversal, but existing passes usually 
don't do that).
3. Do some tricky rewrite using TheX.

I think steps 1 and 2 should be generalized somehow, probably using template 
base class for such tranformations


-- 
Regards,
Konstantin

Reply via email to