]> granicus.if.org Git - llvm/commit
Make the FunctionComparator of the MergeFunctions pass a stand-alone utility.
authorErik Eckstein <eeckstein@apple.com>
Fri, 11 Nov 2016 21:15:13 +0000 (21:15 +0000)
committerErik Eckstein <eeckstein@apple.com>
Fri, 11 Nov 2016 21:15:13 +0000 (21:15 +0000)
commit345d21cba18f85f8a00449dde9596718ab811720
tree860274d969b1733623eb8dae26c4050f07fb81b0
parent6b8a0789f723fe8fc81b04edc08419f5578bc69f
Make the FunctionComparator of the MergeFunctions pass a stand-alone utility.

This is pure refactoring. NFC.

This change moves the FunctionComparator (together with the GlobalNumberState
utility) in to a separate file so that it can be used by other passes.
For example, the SwiftMergeFunctions pass in the Swift compiler:
https://github.com/apple/swift/blob/master/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 a derived comparator class can use them.

Following refactoring helps to share code between the base FunctionComparator
class and a 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286632 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Utils/FunctionComparator.h [new file with mode: 0644]
lib/Transforms/IPO/MergeFunctions.cpp
lib/Transforms/Utils/CMakeLists.txt
lib/Transforms/Utils/FunctionComparator.cpp [new file with mode: 0644]
unittests/Transforms/Utils/CMakeLists.txt
unittests/Transforms/Utils/FunctionComparator.cpp [new file with mode: 0644]