This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] Check for duplicate entries in attribute dictionary during custom parsing
ClosedPublic

Authored by jurahul on Oct 30 2020, 2:32 PM.

Details

Summary
  • Verify that attributes parsed using a custom parser do not have duplicates.
  • If there are duplicated in the attribute dictionary in the input, they get caught during the dictionary parsing.
  • This check verifies that there is no duplication between the parsed dictionary and any attributes that might be added by the custom parser (or when the custom parsing code adds duplicate attributes).
  • Fixes https://bugs.llvm.org/show_bug.cgi?id=48025

Diff Detail

Event Timeline

jurahul created this revision.Oct 30 2020, 2:32 PM
jurahul requested review of this revision.Oct 30 2020, 2:32 PM

Why place this in the declarative parser/printer? This(i.e. duplicate attributes) looks like it could apply to any custom op parser, declarative or not.

By custom op parser, you mean ops that implement their own print and parse functions, right? What do you suggest would be a good place to handle this? In OpBuilder::createOperation() might be too late?

By custom op parser, you mean ops that implement their own print and parse functions, right? What do you suggest would be a good place to handle this? In OpBuilder::createOperation() might be too late?

Yeah. Hmm, can we check here(https://github.com/llvm/llvm-project/blob/72ddd559b8aafef402091f8e192e025022e4ebef/mlir/lib/Parser/Parser.cpp#L848)? If the parser didn't emit an error, we should be able to check if the operation state has duplicate attributes.

jurahul updated this revision to Diff 302347.Nov 2 2020, 11:07 AM

Move error checking to CustomOpParser::parseOperation

rriddle accepted this revision.Nov 3 2020, 1:04 PM

This is really really clean Rahul, awesome!

mlir/include/mlir/IR/Attributes.h
295

nit: name within the given array

mlir/lib/IR/Attributes.cpp
130

Missing a static here.

143–145
mlir/lib/IR/OperationSupport.cpp
40–41
This revision is now accepted and ready to land.Nov 3 2020, 1:04 PM
jurahul updated this revision to Diff 302689.Nov 3 2020, 2:31 PM

Address comments

jurahul retitled this revision from [MLIR] Disallow attributes that are parsed during assembly parsing in the attribute dict. to [MLIR] Check for duplicate entries in attribute dictionary during custom parsing.Nov 3 2020, 2:32 PM
jurahul edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.Nov 3 2020, 4:41 PM
This revision was automatically updated to reflect the committed changes.