From a461faf16b36d248950c4372127ffdcbffcfb3d1 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 21 Mar 2019 15:03:43 -0700 Subject: [PATCH] Fix a PerformanceInliner crash caused by a null callee signature. This is an obvious drive-by fix. It will crash when building Foundation after I commit changes to the pipeline. My attempts at creating a unit test were unsuccessful because it depends on some interaction between inlining and specialization heuristics. --- lib/SILOptimizer/Transforms/PerformanceInliner.cpp | 2 +- lib/SILOptimizer/Utils/Generics.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/SILOptimizer/Transforms/PerformanceInliner.cpp b/lib/SILOptimizer/Transforms/PerformanceInliner.cpp index 3f63706bfd95a..6dbc995f44be3 100644 --- a/lib/SILOptimizer/Transforms/PerformanceInliner.cpp +++ b/lib/SILOptimizer/Transforms/PerformanceInliner.cpp @@ -363,7 +363,7 @@ bool SILPerformanceInliner::isProfitableToInline( auto Subs = FAI.getSubstitutionMap(); // Bail if it is not a generic call or inlining of generics is forbidden. - if (!EnableSILInliningOfGenerics || Subs.empty()) + if (!EnableSILInliningOfGenerics || !Subs.hasAnySubstitutableParams()) continue; if (!isa(def) && !isa(def) && diff --git a/lib/SILOptimizer/Utils/Generics.cpp b/lib/SILOptimizer/Utils/Generics.cpp index 6561bbf19a252..52e7a9d0a3b5f 100644 --- a/lib/SILOptimizer/Utils/Generics.cpp +++ b/lib/SILOptimizer/Utils/Generics.cpp @@ -390,6 +390,8 @@ static bool shouldNotSpecialize(SILFunction *Callee, SILFunction *Caller, bool ReabstractionInfo::prepareAndCheck(ApplySite Apply, SILFunction *Callee, SubstitutionMap ParamSubs, OptRemark::Emitter *ORE) { + assert(ParamSubs.hasAnySubstitutableParams()); + if (shouldNotSpecialize(Callee, Apply ? Apply.getFunction() : nullptr)) return false;