Prefer identifying functions by using symbol ids
The shader translator code is now structured in a way that ensures
that all function definition, function prototype and function call
nodes store the integer symbol id for the function. This is guaranteed
regardless of whether the function node is added while parsing or as a
result of an AST transformation. TIntermAggregate nodes, which include
function calls and constructors can now only be created by calling one
of the TIntermAggregate::Create*() functions to ensure they have all
the necessary properties.
This makes it possible to keep track of functions using integer ids
instead of their mangled name strings when generating the call graph
and when using TLValueTrackingTraverser.
This commit includes a few other small cleanups to the CallDAG class
as well.
BUG=angleproject:1490
TEST=angle_unittests, angle_end2end_tests
Change-Id: Idd1013506cbe4c3380e20d90524a9cd09b890259
Reviewed-on: https://chromium-review.googlesource.com/459603
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index bb08882..bdd68f3 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2490,7 +2490,8 @@
const TSourceLoc &location,
bool insertParametersToSymbolTable)
{
- TIntermFunctionPrototype *prototype = new TIntermFunctionPrototype(function.getReturnType());
+ TIntermFunctionPrototype *prototype =
+ new TIntermFunctionPrototype(function.getReturnType(), TSymbolUniqueId(function));
// TODO(oetuaho@nvidia.com): Instead of converting the function information here, the node could
// point to the data that already exists in the symbol table.
prototype->getFunctionSymbolInfo()->setFromFunction(function);
@@ -2803,9 +2804,8 @@
return TIntermTyped::CreateZero(type);
}
- TIntermAggregate *constructorNode = new TIntermAggregate(type, op, arguments);
+ TIntermAggregate *constructorNode = TIntermAggregate::CreateConstructor(type, op, arguments);
constructorNode->setLine(line);
- ASSERT(constructorNode->isConstructor());
TIntermTyped *constConstructor =
intermediate.foldAggregateBuiltIn(constructorNode, mDiagnostics);
@@ -4533,7 +4533,7 @@
else
{
TIntermAggregate *callNode =
- new TIntermAggregate(fnCandidate->getReturnType(), op, arguments);
+ TIntermAggregate::Create(fnCandidate->getReturnType(), op, arguments);
callNode->setLine(loc);
// Some built-in functions have out parameters too.
@@ -4561,19 +4561,13 @@
// This needs to happen after the function info including name is set.
if (builtIn)
{
- callNode = new TIntermAggregate(fnCandidate->getReturnType(),
- EOpCallBuiltInFunction, arguments);
- // Note that name needs to be set before texture function type is determined.
- callNode->getFunctionSymbolInfo()->setFromFunction(*fnCandidate);
- callNode->setBuiltInFunctionPrecision();
+ callNode = TIntermAggregate::CreateBuiltInFunctionCall(*fnCandidate, arguments);
checkTextureOffsetConst(callNode);
checkImageMemoryAccessForBuiltinFunctions(callNode);
}
else
{
- callNode = new TIntermAggregate(fnCandidate->getReturnType(),
- EOpCallFunctionInAST, arguments);
- callNode->getFunctionSymbolInfo()->setFromFunction(*fnCandidate);
+ callNode = TIntermAggregate::CreateFunctionCall(*fnCandidate, arguments);
checkImageMemoryAccessForUserDefinedFunctions(fnCandidate, callNode);
}