Hash :
b131d25f
Author :
Date :
2020-06-03T10:53:39
Vulkan: Remove validation error suppressions for VVL bug These warnings were generated due to a validation layer bug, which is presumably fixed now. Bug: angleproject:4572 Bug: angleproject:4577 Bug: angleproject:4578 Bug: angleproject:4579 Bug: angleproject:4580 Bug: angleproject:4583 Change-Id: I8799c4e33bc38f83e0fdd364cf6e7eb607c39890 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2227810 Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
//
// Copyright 2002 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// CallDAG.h: Implements a call graph DAG of functions to be re-used accross
// analyses, allows to efficiently traverse the functions in topological
// order.
#include "compiler/translator/CallDAG.h"
#include "compiler/translator/Diagnostics.h"
#include "compiler/translator/SymbolTable.h"
#include "compiler/translator/tree_util/IntermTraverse.h"
namespace sh
{
// The CallDAGCreator does all the processing required to create the CallDAG
// structure so that the latter contains only the necessary variables.
class CallDAG::CallDAGCreator : public TIntermTraverser
{
public:
CallDAGCreator(TDiagnostics *diagnostics)
: TIntermTraverser(true, false, false),
mDiagnostics(diagnostics),
mCurrentFunction(nullptr),
mCurrentIndex(0)
{}
InitResult assignIndices()
{
int skipped = 0;
for (auto &it : mFunctions)
{
// Skip unimplemented functions
if (it.second.definitionNode)
{
InitResult result = assignIndicesInternal(&it.second);
if (result != INITDAG_SUCCESS)
{
return result;
}
}
else
{
skipped++;
}
}
ASSERT(mFunctions.size() == mCurrentIndex + skipped);
return INITDAG_SUCCESS;
}
void fillDataStructures(std::vector<Record> *records, std::map<int, int> *idToIndex)
{
ASSERT(records->empty());
ASSERT(idToIndex->empty());
records->resize(mCurrentIndex);
for (auto &it : mFunctions)
{
CreatorFunctionData &data = it.second;
// Skip unimplemented functions
if (!data.definitionNode)
{
continue;
}
ASSERT(data.index < records->size());
Record &record = (*records)[data.index];
record.node = data.definitionNode;
record.callees.reserve(data.callees.size());
for (auto &callee : data.callees)
{
record.callees.push_back(static_cast<int>(callee->index));
}
(*idToIndex)[it.first] = static_cast<int>(data.index);
}
}
private:
struct CreatorFunctionData
{
CreatorFunctionData()
: definitionNode(nullptr), name(""), index(0), indexAssigned(false), visiting(false)
{}
std::set<CreatorFunctionData *> callees;
TIntermFunctionDefinition *definitionNode;
ImmutableString name;
size_t index;
bool indexAssigned;
bool visiting;
};
bool visitFunctionDefinition(Visit visit, TIntermFunctionDefinition *node) override
{
// Create the record if need be and remember the definition node.
mCurrentFunction = &mFunctions[node->getFunction()->uniqueId().get()];
// Name will be overwritten here. If we've already traversed the prototype of this function,
// it should have had the same name.
ASSERT(mCurrentFunction->name == "" ||
mCurrentFunction->name == node->getFunction()->name());
mCurrentFunction->name = node->getFunction()->name();
mCurrentFunction->definitionNode = node;
node->getBody()->traverse(this);
mCurrentFunction = nullptr;
return false;
}
void visitFunctionPrototype(TIntermFunctionPrototype *node) override
{
ASSERT(mCurrentFunction == nullptr);
// Function declaration, create an empty record.
auto &record = mFunctions[node->getFunction()->uniqueId().get()];
record.name = node->getFunction()->name();
}
// Track functions called from another function.
bool visitAggregate(Visit visit, TIntermAggregate *node) override
{
if (node->getOp() == EOpCallFunctionInAST)
{
// Function call, add the callees
auto it = mFunctions.find(node->getFunction()->uniqueId().get());
ASSERT(it != mFunctions.end());
// We might be traversing the initializer of a global variable. Even though function
// calls in global scope are forbidden by the parser, some subsequent AST
// transformations can add them to emulate particular features.
if (mCurrentFunction)
{
mCurrentFunction->callees.insert(&it->second);
}
}
return true;
}
// Recursively assigns indices to a sub DAG
InitResult assignIndicesInternal(CreatorFunctionData *root)
{
// Iterative implementation of the index assignment algorithm. A recursive version
// would be prettier but since the CallDAG creation runs before the limiting of the
// call depth, we might get stack overflows (computation of the call depth uses the
// CallDAG).
ASSERT(root);
if (root->indexAssigned)
{
return INITDAG_SUCCESS;
}
// If we didn't have to detect recursion, functionsToProcess could be a simple queue
// in which we add the function being processed's callees. However in order to detect
// recursion we need to know which functions we are currently visiting. For that reason
// functionsToProcess will look like a concatenation of segments of the form
// [F visiting = true, subset of F callees with visiting = false] and the following
// segment (if any) will be start with a callee of F.
// This way we can remember when we started visiting a function, to put visiting back
// to false.
TVector<CreatorFunctionData *> functionsToProcess;
functionsToProcess.push_back(root);
InitResult result = INITDAG_SUCCESS;
std::stringstream errorStream = sh::InitializeStream<std::stringstream>();
while (!functionsToProcess.empty())
{
CreatorFunctionData *function = functionsToProcess.back();
if (function->visiting)
{
function->visiting = false;
function->index = mCurrentIndex++;
function->indexAssigned = true;
functionsToProcess.pop_back();
continue;
}
if (!function->definitionNode)
{
errorStream << "Undefined function '" << function->name
<< "()' used in the following call chain:";
result = INITDAG_UNDEFINED;
break;
}
if (function->indexAssigned)
{
functionsToProcess.pop_back();
continue;
}
function->visiting = true;
for (auto callee : function->callees)
{
functionsToProcess.push_back(callee);
// Check if the callee is already being visited after pushing it so that it appears
// in the chain printed in the info log.
if (callee->visiting)
{
errorStream << "Recursive function call in the following call chain:";
result = INITDAG_RECURSION;
break;
}
}
if (result != INITDAG_SUCCESS)
{
break;
}
}
// The call chain is made of the function we were visiting when the error was detected.
if (result != INITDAG_SUCCESS)
{
bool first = true;
for (auto function : functionsToProcess)
{
if (function->visiting)
{
if (!first)
{
errorStream << " -> ";
}
errorStream << function->name << ")";
first = false;
}
}
if (mDiagnostics)
{
std::string errorStr = errorStream.str();
mDiagnostics->globalError(errorStr.c_str());
}
}
return result;
}
TDiagnostics *mDiagnostics;
std::map<int, CreatorFunctionData> mFunctions;
CreatorFunctionData *mCurrentFunction;
size_t mCurrentIndex;
};
// CallDAG
CallDAG::CallDAG() {}
CallDAG::~CallDAG() {}
const size_t CallDAG::InvalidIndex = std::numeric_limits<size_t>::max();
size_t CallDAG::findIndex(const TSymbolUniqueId &id) const
{
auto it = mFunctionIdToIndex.find(id.get());
if (it == mFunctionIdToIndex.end())
{
return InvalidIndex;
}
else
{
return it->second;
}
}
const CallDAG::Record &CallDAG::getRecordFromIndex(size_t index) const
{
ASSERT(index != InvalidIndex && index < mRecords.size());
return mRecords[index];
}
size_t CallDAG::size() const
{
return mRecords.size();
}
void CallDAG::clear()
{
mRecords.clear();
mFunctionIdToIndex.clear();
}
CallDAG::InitResult CallDAG::init(TIntermNode *root, TDiagnostics *diagnostics)
{
CallDAGCreator creator(diagnostics);
// Creates the mapping of functions to callees
root->traverse(&creator);
// Does the topological sort and detects recursions
InitResult result = creator.assignIndices();
if (result != INITDAG_SUCCESS)
{
return result;
}
creator.fillDataStructures(&mRecords, &mFunctionIdToIndex);
return INITDAG_SUCCESS;
}
} // namespace sh