From f525a497eabad6686645a9f7dd8d58875545c7a5 Mon Sep 17 00:00:00 2001 From: Mahesh Ravishankar Date: Thu, 8 Aug 2019 14:40:03 -0700 Subject: [PATCH] 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 --- mlir/lib/Dialect/SPIRV/SPIRVOps.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp index a7574a51659e..cdd10137920b 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -768,13 +768,14 @@ static LogicalResult verify(spirv::ModuleOp moduleOp) { auto &body = op.getRegion(0).front(); llvm::DenseMap, 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(op)) { - auto funcOp = moduleOp.lookupSymbol(entryPointOp.fn()); + auto funcOp = table.lookup(entryPointOp.fn()); if (!funcOp) { return entryPointOp.emitError("function '") << entryPointOp.fn() << "' not found in 'spv.module'";