[passmanager] Change the optimizer to use SILOptFunctionBuilder.

I am going to add the code in a bit that does the notifications. I tried to pass
down the builder instead of the pass manager. I also tried not to change the
formatting.

rdar://42301529
This commit is contained in:
Michael Gottesman
2018-08-05 17:51:51 -07:00
parent b3c9dbeb9f
commit b72304415d
26 changed files with 264 additions and 135 deletions

View File

@@ -23,6 +23,7 @@
#include "swift/SILOptimizer/Utils/Generics.h"
#include "swift/SILOptimizer/Utils/Local.h"
#include "swift/SILOptimizer/PassManager/Transforms.h"
#include "swift/SILOptimizer/Utils/SILOptFunctionBuilder.h"
#include "llvm/ADT/SmallVector.h"
using namespace swift;
@@ -48,6 +49,7 @@ class GenericSpecializer : public SILFunctionTransform {
} // end anonymous namespace
bool GenericSpecializer::specializeAppliesInFunction(SILFunction &F) {
SILOptFunctionBuilder FunctionBuilder(*getPassManager());
DeadInstructionSet DeadApplies;
llvm::SmallSetVector<SILInstruction *, 8> Applies;
OptRemark::Emitter ORE(DEBUG_TYPE, F.getModule());
@@ -101,7 +103,8 @@ bool GenericSpecializer::specializeAppliesInFunction(SILFunction &F) {
// We have a call that can potentially be specialized, so
// attempt to do so.
llvm::SmallVector<SILFunction *, 2> NewFunctions;
trySpecializeApplyOfGeneric(Apply, DeadApplies, NewFunctions, ORE);
trySpecializeApplyOfGeneric(FunctionBuilder, Apply, DeadApplies,
NewFunctions, ORE);
// Remove all the now-dead applies. We must do this immediately
// rather than defer it in order to avoid problems with cloning