Hi Konstantin,

On 5/11/13 12:08 PM, Konstantin Tokarev wrote:
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.

Yes.
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)



Yeah, these transformations are addressable.

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

Same above.

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?


Cool, could you share this pass with us? Generating a few incompilable code is fine, especially approaching the end of reduction, there wouldn't have many failing transformations.

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).

Yes, a pass usually searches all possible transformation opportunities and exists normally. I chose this approach due to some laziness: if you try --help option, you will see a command line --query-instances, which tells you how many transformation instances we could do for a given pass. During AST traversal, I don't check if we are only querying instances or performing actual transformation. Anyway, it should be easily done by adding a flag to differentiate these two behaviors.

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



Quite a few passes have boilerplate code, although not direct-copy-paste-like code, they all share the same workflow as you mention. I did certain refactoring work a while ago, for example, some code were put into templates or the base class. I will think about it.

Again, thanks for the comments and suggestions!

- Yang



Reply via email to