[llvm-dev] Hash of a module
Kevin Modzelewski via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 22 22:24:56 PST 2015
I've tried this kind of thing before -- one thing to be aware of is that
some code will not converge on a single fixed point under repeated
optimizations, and instead will cycle through a couple different versions.
So regardless of the way you have of determining if changes were made, the
cycle case might need to be taken into account. I handled it by saying
"stop if the number of IR instructions increases" which ended up being a
decent heuristic for my use case (starting from something very unoptimized
so there were a lot of optimizations available). This was probably a bug I
was running into and it might have been fixed (I think this was using llvm
3.3), so not sure if this will end up affecting you.
I also ran into another case where the "changes made" flag was set despite
no changes in the IR. My sense is that this feature is not used very often
so these kind of things can sneak in. Anyway, here's the patch, not sure
if it is still relevant.
On Sun, Dec 20, 2015 at 4:43 AM, Russell Wallace via llvm-dev <
llvm-dev at lists.llvm.org> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev