[mlir][drr] Improve error message for unexpected attribute (NFC)

When using an attribute where a value is expected previously this would fail
complaining about unbound symbol. Instead make error clear and mention common
failure reason.
This commit is contained in:
Jacques Pienaar 2021-08-10 13:03:52 -07:00
parent 178da37b18
commit 768a517581
1 changed files with 8 additions and 0 deletions

View File

@ -1295,6 +1295,14 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs(
childNodeNames.lookup(argIndex));
} else {
DagLeaf leaf = node.getArgAsLeaf(argIndex);
if (leaf.isConstantAttr())
// TODO: Use better location
PrintFatalError(
loc,
"attribute found where value was expected, if attempting to use "
"constant value, construct a constant op with given attribute "
"instead");
auto symbol =
symbolInfoMap.getValueAndRangeUse(node.getArgName(argIndex));
if (leaf.isNativeCodeCall()) {