Build SymbolTable upfront in ModuleOp verification.

Building the symbol table upfront from module op allows for O(1)
lookup of the function while verifying duplicate EntryPointOp within
the module.

PiperOrigin-RevId: 262435697
This commit is contained in:
Mahesh Ravishankar 2019-08-08 14:40:03 -07:00 committed by A. Unique TensorFlower
parent b448266a09
commit f525a497ea
1 changed files with 2 additions and 1 deletions

View File

@ -768,13 +768,14 @@ static LogicalResult verify(spirv::ModuleOp moduleOp) {
auto &body = op.getRegion(0).front();
llvm::DenseMap<std::pair<FuncOp, spirv::ExecutionModel>, spirv::EntryPointOp>
entryPoints;
SymbolTable table(moduleOp);
for (auto &op : body) {
if (op.getDialect() == dialect) {
// For EntryPoint op, check that the function and execution model is not
// duplicated in EntryPointOps
if (auto entryPointOp = llvm::dyn_cast<spirv::EntryPointOp>(op)) {
auto funcOp = moduleOp.lookupSymbol(entryPointOp.fn());
auto funcOp = table.lookup<FuncOp>(entryPointOp.fn());
if (!funcOp) {
return entryPointOp.emitError("function '")
<< entryPointOp.fn() << "' not found in 'spv.module'";