Implement gradient operation AST analysis

This will allow narrowing down which usages of
[[flatten]] and [[unroll]] are actually useful.

BUG=angleproject:937
BUG=395048

Change-Id: Ib8d7b98431b8cd3563e1eff8ecc9ed5df1a9b7d6
Reviewed-on: https://chromium-review.googlesource.com/263775
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index d52f3a8..80782e2 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -172,6 +172,7 @@
 {
     mContainsLoopDiscontinuity = mShaderType == GL_FRAGMENT_SHADER && containsLoopDiscontinuity(treeRoot);
     mContainsAnyLoop = containsAnyLoop(treeRoot);
+
     const std::vector<TIntermTyped*> &flaggedStructs = FlagStd140ValueStructs(treeRoot);
     makeFlaggedStructMaps(flaggedStructs);
 
@@ -186,6 +187,14 @@
     InitBuiltInFunctionEmulatorForHLSL(&builtInFunctionEmulator);
     builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(treeRoot);
 
+    // Now that we are done changing the AST, do the analyses need for HLSL generation
+    {
+        CallDAG dag;
+        CallDAG::InitResult success = dag.init(treeRoot, &objSink);
+        ASSERT(success == CallDAG::INITDAG_SUCCESS);
+        mASTAnalyses = CreateASTMetadataHLSL(treeRoot, dag);
+    }
+
     // Output the body and footer first to determine what has to go in the header
     mInfoSinkStack.push(&mBody);
     treeRoot->traverse(this);