@@ -40,6 +40,27 @@ STATISTIC(NumMandatoryInlines,
4040 " Number of function application sites inlined by the mandatory "
4141 " inlining pass" );
4242
43+ // ===----------------------------------------------------------------------===//
44+ // Printing Helpers
45+ // ===----------------------------------------------------------------------===//
46+
47+ extern llvm::cl::opt<bool > SILPrintInliningCallee;
48+
49+ extern llvm::cl::opt<bool > SILPrintInliningCallerBefore;
50+
51+ extern llvm::cl::opt<bool > SILPrintInliningCallerAfter;
52+
53+ extern void printInliningDetailsCallee (StringRef passName, SILFunction *caller,
54+ SILFunction *callee);
55+
56+ extern void printInliningDetailsCallerBefore (StringRef passName,
57+ SILFunction *caller,
58+ SILFunction *callee);
59+
60+ extern void printInliningDetailsCallerAfter (StringRef passName,
61+ SILFunction *caller,
62+ SILFunction *callee);
63+
4364template <typename ...T, typename ...U>
4465static void diagnose (ASTContext &Context, SourceLoc loc, Diag<T...> diag,
4566 U &&...args) {
@@ -923,11 +944,21 @@ runOnFunctionRecursively(SILOptFunctionBuilder &FuncBuilder, SILFunction *F,
923944
924945 invalidatedStackNesting |= Inliner.invalidatesStackNesting (InnerAI);
925946
947+ if (SILPrintInliningCallee) {
948+ printInliningDetailsCallee (" MandatoryInlining" , F, CalleeFunction);
949+ }
950+ if (SILPrintInliningCallerBefore) {
951+ printInliningDetailsCallerBefore (" MandatoryInlining" , F,
952+ CalleeFunction);
953+ }
926954 // Inlining deletes the apply, and can introduce multiple new basic
927955 // blocks. After this, CalleeValue and other instructions may be invalid.
928956 // nextBB will point to the last inlined block
929957 SILBasicBlock *lastBB =
930958 Inliner.inlineFunction (CalleeFunction, InnerAI, FullArgs);
959+ if (SILPrintInliningCallerAfter) {
960+ printInliningDetailsCallerAfter (" MandatoryInlining" , F, CalleeFunction);
961+ }
931962 nextBB = lastBB->getReverseIterator ();
932963 ++NumMandatoryInlines;
933964
0 commit comments