This is an archive of the discontinued LLVM Phabricator instance.

Add similar function merging to MergeFunctions
Needs ReviewPublic

Authored by tvkoch on Jan 22 2014, 8:35 AM.

Details

Reviewers
None
Group Reviewers
deleted
Summary

The patch adds functionality to MergeFunctions to merge not just identical but also similar functions. Details were presented at the US LLVM conference, see: http://llvm.org/devmtg/2013-11/#talk3 & http://llvm.org/devmtg/2013-11/slides/Koch-FunctionMerging.pdf

This is a new revision of the patch previously posted by Pranav Bhandarkar on 01/16.

Changes:

  • Fix passing of choice argument
  • Respect minimum similarity threshold
  • Allow merging of functions containing InvokeInsts
  • Improve hashing function to include size of first BB
  • Better debug output

Diff Detail

Event Timeline

Looks like this never made it to the project mailing lists. Did you intend to send this out for full review? If so, you should add llvm-commits to the CC field.

tvkoch added subscribers: Unknown Object (MLST), nicholas.Apr 5 2014, 5:27 PM

Oh right - didn't realise commits wasn't on there! Also CCing Nick.

There has been some work on MergeFunctions recently by Stepan so it probably needs to be rebased.

Stepan - are you still working on this? If I recall correctly, you were considering implementing similar function merging on top of your ordering-based approach. I currently don't have the resources to completely rewrite the patch. If we want to support similar function merging right now, I see two options:

a) try and add this as-is to MergeFunctions but this would likely mean we can't do your ordering-based merging,
b) split MergeFunctions into two passes, one for merging identical functions (it could use your faster algorithm) and another just for similar function merging (based on parts of this patch).

It would be nice to get this into trunk, because the results are good and it is in active use by customers. We also have an upcoming paper at LCTES with a more thorough evaluation.

Hi Tobias,

You idea is really great! Thanks for working on it.
Though, you patch still contains some things to be fixed:

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140127/203297.html

Perhaps it would be good to implement similar merging itself as separate
pass, that is based on MergeFunctions results. All you need from
MergeFunctions is kind of FunctionToFunction map? Right? Now it mostly
implemented as SimilarFnMap in your patch. I think, I could prepare that
kind of data for you in my patches.

In mean time I'd propose you to focus on merging process, since I got a
lot of failures on my machine with your patch applied. Merging process
is most delicate and dainty here. Averything depends on quality of this
part. Note, there is a buildbot, that tests MergeFunctions pass:
http://lab.llvm.org:8011/builders/clang-mergefunc-x86_64-freeBSD9.2

We could boost things up and move your patch into trunk faster, if you
prepare clean and well made patch for second part: merging itself. On
the top, I think, it should look somewhat like:

void mergeSimilarFunctions(Function *FL, Function *FR, Instruction
*MergeStart, Instruction *MergeEnd);

-Stepan

Tobias von Koch wrote:

Oh right - didn't realise commits wasn't on there! Also CCing Nick.

There has been some work on MergeFunctions recently by Stepan so it probably needs to be rebased.

Stepan - are you still working on this? If I recall correctly, you were considering implementing similar function merging on top of your ordering-based approach. I currently don't have the resources to completely rewrite the patch. If we want to support similar function merging right now, I see two options:

a) try and add this as-is to MergeFunctions but this would likely mean we can't do your ordering-based merging,
b) split MergeFunctions into two passes, one for merging identical functions (it could use your faster algorithm) and another just for similar function merging (based on parts of this patch).

It would be nice to get this into trunk, because the results are good and it is in active use by customers. We also have an upcoming paper at LCTES with a more thorough evaluation.

http://reviews.llvm.org/D2591


llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits