[PATCH] D25385: Make the FunctionComparator of the MergeFunctions pass a stand-alone utility in a separate file
Erik Eckstein via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 16:57:15 PDT 2016
eeckstein created this revision.
eeckstein added reviewers: jfb, dyatkovskiy, nicholas.
eeckstein added a subscriber: llvm-commits.
Herald added subscribers: modocache, mgorny, beanz.
This is pure refactoring. NFC.
Motivation: in the swift compiler we have a pass, called SwiftMergeFunctions, which is a modified version of llvm's MergeFunctions:
https://github.com/apple/swift/blob/master/lib/LLVMPasses/LLVMMergeFunctions.cpp
The purpose of SwiftMergeFunctions is to merge _similar_ functions which only differ by some constants. It's used to merge specialized generic functions.
Some background info: it's important that SwiftMergeFunctions runs _after_ llvm's MergeFunctions, because we want to merge similar functions only after all equivalent functions are already merged.
SwiftMergeFunctions shares most of the FunctionComparator code with the llvm pass. Currently this code is just copied.
This change moves the FunctionComparator (together with the GlobalNumberState utility) in to a separate file so that it can be used by both passes. The SwiftMergeFunctions pass derives its own comparator from FunctionComparator. This is how it looks like: https://github.com/eeckstein/swift/blob/merge-func-refactor/lib/LLVMPasses/LLVMMergeFunctions.cpp
Details of the change:
*) The big part is just moving code out of MergeFunctions.cpp into FunctionComparator.h/cpp
*) Make FunctionComparator member functions protected (instead of private) so that the derived comparator in SwiftMergeFunctions can use them.
Following refactoring helps to share code between the base FunctionComparator class and the derived class:
*) Add a beginCompare() function
*) Move some basic function property comparisons into a separate function compareSignature()
*) Do the GEP comparison inside cmpOperations() which now has a new needToCmpOperands reference parameter
https://reviews.llvm.org/D25385
Files:
include/llvm/Transforms/Utils/FunctionComparator.h
lib/Transforms/IPO/MergeFunctions.cpp
lib/Transforms/Utils/CMakeLists.txt
lib/Transforms/Utils/FunctionComparator.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25385.73999.patch
Type: text/x-patch
Size: 103109 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/f81cc332/attachment.bin>
More information about the llvm-commits
mailing list