<div dir="ltr">Thanks! The code to create a copy of a module is just what I needed; having done that, I've written my own code to compare modules for approximate equality, since I realized for my purposes, a fast, coarse-grained comparison suffices (since coarse-grained changes are the most likely to create further optimization opportunities).<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 20, 2015 at 2:29 PM, Manuel Jacob <span dir="ltr"><<a href="mailto:me@manueljacob.de" target="_blank">me@manueljacob.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Russell,<br>
<br>
please take a look at the file lib/Transforms/IPO/MergeFunctions.cpp. It implements comparison and hashing of functions. You can probably reuse some of it's code and extend the approach to modules. Alternatively, you could try to use code from tools/llvm-diff/ (DifferenceEngine.cpp in particular). They both implement similar functionality, one might be better suited for your particular use case.<br>
<br>
There is code to create a copy of a module in lib/Transforms/Utils/CloneModule.cpp.<br>
<br>
-Manuel<div><div class="h5"><br>
<br>
On 2015-12-20 13:43, Russell Wallace via llvm-dev wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
I want to run a bunch of optimizations, iteratively, that is keep running<br>
until things stop changing (to make sure all optimization opportunities are<br>
taken). As far as I know, there is no way to copy a module or compare<br>
modules by value, so it occurs to me that a practical solution might be to<br>
take the hash code of the module and see if that changes.<br>
<br>
A problem is that hash algorithms are designed to work on streams of bytes,<br>
not compound objects.<br>
<br>
First attempt at a solution: iterate through all instructions in all<br>
functions and hash the instruction kinds. I can think of some possible<br>
changes that would fail to be captured by that.<br>
<br>
Is there any already known solution?<br>
<br></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote>
</blockquote></div><br></div>