On Fri, 2011-12-02 at 11:02 +0100, Stephan Bergmann wrote:
On 12/01/2011 04:52 PM, David Malcolm wrote:
> As for detecting where the result gets compared against 0, I'm not sure
> of the best way to do this. Perhaps you could run your pass after the
> code is in SSA form, and then identify exactly which variables hold
> result values from a getLength() call, and then look for comparisons
> with them against 0. Am not sure how copy-propagation works yet, so
> this is just a suggestion.
I got a script working now that runs after cfg and finds a decent number
of occurrences of what I wanted it to find, and not too many false
positives. The script is at
<
https://bugs.freedesktop.org/attachment.cgi?id=54059>, if anyone's
interested (belonging to a LibreOffice cleanup bug at
<
https://bugs.freedesktop.org/show_bug.cgi?id=43460>).
Excellent, thanks!
I've taken the liberty of adding this to the plugin's "Success Stories"
page here:
http://gcc-python-plugin.readthedocs.org/en/latest/success.html
Hope that's OK
I had a look at LibreOffice's bugzilla, and it struck me that this might
be something that the plugin could help with: find global variables with
non-trivial constructors:
https://bugs.freedesktop.org/show_bug.cgi?id=38835
You can already see these by examining the built binaries by section,
but it's probably _much_ easier to find and remove them by doing this in
the compiler, so that you get source line information during the
compile. Anyone interested in writing a script to detect these? It may
need a little work to expose more of GCC's C++ internals to the Python
interface.
Maybe it's worth putting together an "ideas" page for things that people
might want to try using the plugin for?
Do people have other ideas for scripts? (and do I need to do anything to
help e.g. to expose more of GCC's insides to the Python interface?).
What is it that you've always wanted the compiler to do for you? [1]
Dave
[1] and no,
http://xkcd.com/149/ doesn't count :)