Add program-settings flag to disable the inliner.

Change-Id: I6c4e7f6a2aab6710221029022a3a5f3ec323c5e2
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/317856
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 4497b9b..db5dc3e 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -351,16 +351,14 @@
         fIRGenerator->fSymbolTable = std::move(base);
     }
     Program::Settings settings;
+    settings.fInline = false;
 #if !defined(SKSL_STANDALONE) & SK_SUPPORT_GPU
     GrContextOptions opts;
     GrShaderCaps caps(opts);
     settings.fCaps = &caps;
 #endif
-    SkASSERT(fIRGenerator->fCanInline);
-    fIRGenerator->fCanInline = false;
     fIRGenerator->start(&settings, nullptr, true);
     fIRGenerator->convertProgram(kind, source->c_str(), source->length(), outElements);
-    fIRGenerator->fCanInline = true;
     if (this->fErrorCount) {
         printf("Unexpected errors: %s\n", this->fErrorText.c_str());
     }
@@ -1683,7 +1681,9 @@
         }
 
         // Perform inline-candidate analysis and inline any functions deemed suitable.
-        madeChanges |= fInliner.analyze(program);
+        if (program.fSettings.fInline) {
+            madeChanges |= fInliner.analyze(program);
+        }
 
         // Remove dead functions. We wait until after analysis so that we still report errors,
         // even in unused code.
diff --git a/src/sksl/SkSLIRGenerator.h b/src/sksl/SkSLIRGenerator.h
index 9e06c9c..1bc0fd6 100644
--- a/src/sksl/SkSLIRGenerator.h
+++ b/src/sksl/SkSLIRGenerator.h
@@ -186,7 +186,6 @@
     const Variable* fRTAdjustInterfaceBlock;
     int fRTAdjustFieldIndex;
     int fTmpSwizzleCounter;
-    bool fCanInline = true;
     // true if we are currently processing one of the built-in SkSL include files
     bool fIsBuiltinCode;
 
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
index 21c57bc..e47879b 100644
--- a/src/sksl/SkSLMain.cpp
+++ b/src/sksl/SkSLMain.cpp
@@ -146,6 +146,9 @@
                 if (settingsText.consumeSuffix(" ForceHighPrecision")) {
                     settings->fForceHighPrecision = true;
                 }
+                if (settingsText.consumeSuffix(" NoInline")) {
+                    settings->fInline = false;
+                }
                 if (settingsText.consumeSuffix(" Sharpen")) {
                     settings->fSharpenTextures = true;
                 }
diff --git a/src/sksl/ir/SkSLProgram.h b/src/sksl/ir/SkSLProgram.h
index 6ae2d73..a16041c 100644
--- a/src/sksl/ir/SkSLProgram.h
+++ b/src/sksl/ir/SkSLProgram.h
@@ -120,8 +120,10 @@
         // Functions smaller than this (measured in IR nodes) will be inlined. Default is arbitrary.
         // Set to 0 to disable inlining entirely.
         int fInlineThreshold = 50;
-        // true to enable optimization passes
+        // True to enable optimization passes.
         bool fOptimize = true;
+        // True to enable the inliner.
+        bool fInline = true;
         // If true, implicit conversions to lower precision numeric types are allowed
         // (eg, float to half)
         bool fAllowNarrowingConversions = false;