[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[creduce-dev] Creduce example with potential improvements



Hi,

Thanks for your work on the creduce project. I've used creduce for a while and find it very effective. That said there I do find cases where it could do a better job so here is an example.

This hits an assertion failure with LLVM/Clang r343902 on Linux. creduce 2.8.0 got it down to the file in test.cpp (1305 bytes), with some manual simplifications I got it down to minimal.cpp (240 bytes, probably not the absolute minimum but small enough). The assertion is in the back end of the compiler so C++ classes and templates are likely irrelevant but creduce is not able to get rid of them.

Some of the techniques I used to reduce it further were:
* Collapsing type hierarchy (moving e() into ad)
* Collapsing nested structs (moving the contents of ae into ad)
* Changing e() from a template function into a non-templated function. I'm not sure why creduce was unable to do this as neither template parameter is used
* Duplicating template classes depending on the types used for instantiation. i.e. Copy class b to a class b_int and replace b<int> with b_int<int>. This runs the risk of increasing the size of the file but I find this opens up other opportunities for creduce to simplify each of those classes independently
* Converting methods into functions (e.g. d::d() can be replaced with void foo())
* Replacing sizeof(long) and sizeof(int) with 8 and 4 respectively. This will, of course, depend on the machine but maybe creduce could try some plausible size replacements.
* Replacing class { public: ... } with struct { ... }. This should be equivalent and reduces the number of tokens.

I hope this is useful information.

Regards
Russ

Attachment: example.tgz
Description: application/compressed