76
76
#include " swift/AST/DiagnosticsSIL.h"
77
77
#include " swift/AST/Expr.h"
78
78
#include " swift/AST/Module.h"
79
+ #include " swift/AST/SemanticAttrs.h"
79
80
#include " swift/AST/SubstitutionMap.h"
80
81
#include " swift/Basic/OptimizationMode.h"
81
- #include " swift/AST/SemanticAttrs.h"
82
82
#include " swift/Demangling/Demangle.h"
83
83
#include " swift/Demangling/Demangler.h"
84
+ #include " swift/SIL/BasicBlockBits.h"
84
85
#include " swift/SIL/BasicBlockUtils.h"
85
86
#include " swift/SIL/CFG.h"
86
87
#include " swift/SIL/InstructionUtils.h"
93
94
#include " swift/SIL/SILLocation.h"
94
95
#include " swift/SIL/SILModule.h"
95
96
#include " swift/SIL/TypeLowering.h"
96
- #include " swift/SIL/BasicBlockBits.h"
97
97
#include " swift/SILOptimizer/PassManager/Passes.h"
98
98
#include " swift/SILOptimizer/PassManager/Transforms.h"
99
99
#include " swift/SILOptimizer/Utils/CFGOptUtils.h"
100
+ #include " swift/SILOptimizer/Utils/CompileTimeInterpolationUtils.h"
100
101
#include " swift/SILOptimizer/Utils/ConstExpr.h"
101
102
#include " swift/SILOptimizer/Utils/InstructionDeleter.h"
102
103
#include " swift/SILOptimizer/Utils/SILInliner.h"
@@ -245,38 +246,6 @@ static bool isIntegerOrBoolType(SILType silType, ASTContext &astContext) {
245
246
return nominalDecl && isStdlibIntegerOrBoolDecl (nominalDecl, astContext);
246
247
}
247
248
248
- // / Decide if the given instruction (which could possibly be a call) should
249
- // / be constant evaluated.
250
- // /
251
- // / \returns true iff the given instruction is not a call or if it is, it calls
252
- // / a known constant-evaluable function such as string append etc., or calls
253
- // / a function annotate as "constant_evaluable".
254
- static bool shouldAttemptEvaluation (SILInstruction *inst) {
255
- auto *apply = dyn_cast<ApplyInst>(inst);
256
- if (!apply)
257
- return true ;
258
- SILFunction *calleeFun = apply->getCalleeFunction ();
259
- if (!calleeFun)
260
- return false ;
261
- return isConstantEvaluable (calleeFun);
262
- }
263
-
264
- // / Skip or evaluate the given instruction based on the evaluation policy and
265
- // / handle errors. The policy is to evaluate all non-apply instructions as well
266
- // / as apply instructions that are marked as "constant_evaluable".
267
- static std::pair<Optional<SILBasicBlock::iterator>, Optional<SymbolicValue>>
268
- evaluateOrSkip (ConstExprStepEvaluator &stepEval,
269
- SILBasicBlock::iterator instI) {
270
- SILInstruction *inst = &(*instI);
271
-
272
- // Note that skipping a call conservatively approximates its effects on the
273
- // interpreter state.
274
- if (shouldAttemptEvaluation (inst)) {
275
- return stepEval.tryEvaluateOrElseMakeEffectsNonConstant (instI);
276
- }
277
- return stepEval.skipByMakingEffectsNonConstant (instI);
278
- }
279
-
280
249
// / Return true iff the given value is a stdlib Int or Bool and it not a direct
281
250
// / construction of Int or Bool.
282
251
static bool isFoldableIntOrBool (SILValue value, ASTContext &astContext) {
@@ -818,31 +787,6 @@ static SILValue emitCodeForSymbolicValue(SymbolicValue symVal,
818
787
}
819
788
}
820
789
821
- // / Given a SILValue \p value, compute the set of transitive users of the value
822
- // / (excluding value itself) by following the use-def chain starting at value.
823
- // / Note that this function does not follow use-def chains though branches.
824
- static void getTransitiveUsers (SILValue value,
825
- SmallVectorImpl<SILInstruction *> &users) {
826
- // Collect the instructions that are data dependent on the value using a
827
- // fix point iteration.
828
- SmallPtrSet<SILInstruction *, 16 > visitedUsers;
829
- SmallVector<SILValue, 16 > worklist;
830
- worklist.push_back (value);
831
-
832
- while (!worklist.empty ()) {
833
- SILValue currVal = worklist.pop_back_val ();
834
- for (Operand *use : currVal->getUses ()) {
835
- SILInstruction *user = use->getUser ();
836
- if (visitedUsers.count (user))
837
- continue ;
838
- visitedUsers.insert (user);
839
- llvm::copy (user->getResults (), std::back_inserter (worklist));
840
- }
841
- }
842
- // At this point, visitedUsers have all the transitive, data-dependent uses.
843
- users.append (visitedUsers.begin (), visitedUsers.end ());
844
- }
845
-
846
790
// / Collect the end points of the instructions that are data dependent on \c
847
791
// / value. A instruction is data dependent on \c value if its result may
848
792
// / transitively depends on \c value. Note that data dependencies through
@@ -853,7 +797,7 @@ static void getTransitiveUsers(SILValue value,
853
797
// / \param endUsers buffer for storing the found end points of the data
854
798
// / dependence chain.
855
799
static void
856
- getEndPointsOfDataDependentChain (SILValue value, SILFunction *fun,
800
+ getEndPointsOfDataDependentChain (SingleValueInstruction * value, SILFunction *fun,
857
801
SmallVectorImpl<SILInstruction *> &endUsers) {
858
802
assert (!value->getType ().isAddress ());
859
803
0 commit comments