[llvm-dev] Hash of a module

Manuel Jacob via llvm-dev llvm-dev at lists.llvm.org
Sun Dec 20 06:29:30 PST 2015


Hi Russell,

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.

There is code to create a copy of a module in 
lib/Transforms/Utils/CloneModule.cpp.

-Manuel

On 2015-12-20 13:43, Russell Wallace via llvm-dev wrote:
> I want to run a bunch of optimizations, iteratively, that is keep 
> running
> until things stop changing (to make sure all optimization opportunities 
> are
> taken). As far as I know, there is no way to copy a module or compare
> modules by value, so it occurs to me that a practical solution might be 
> to
> take the hash code of the module and see if that changes.
> 
> A problem is that hash algorithms are designed to work on streams of 
> bytes,
> not compound objects.
> 
> First attempt at a solution: iterate through all instructions in all
> functions and hash the instruction kinds. I can think of some possible
> changes that would fail to be captured by that.
> 
> Is there any already known solution?
> 
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list