forked from OSchip/llvm-project
[mlir] Fix ConstantOp verifier
This restricts the attributes to integers for constants of type IndexType. So far an attribute like StringAttr as in %c1 = constant "" : index is valid. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D98216
This commit is contained in:
parent
154395536e
commit
849f8183fb
|
@ -1205,10 +1205,9 @@ static LogicalResult verify(ConstantOp &op) {
|
|||
return op.emitOpError() << "requires attribute's type (" << value.getType()
|
||||
<< ") to match op's return type (" << type << ")";
|
||||
|
||||
if (type.isa<IndexType>() || value.isa<BoolAttr>())
|
||||
return success();
|
||||
|
||||
if (auto intAttr = value.dyn_cast<IntegerAttr>()) {
|
||||
if (type.isa<IndexType>() || value.isa<BoolAttr>())
|
||||
return success();
|
||||
IntegerType intType = type.cast<IntegerType>();
|
||||
if (!intType.isSignless())
|
||||
return op.emitOpError("requires integer result types to be signless");
|
||||
|
|
|
@ -247,3 +247,11 @@ func @non_signless_constant() {
|
|||
%0 = constant 0 : si32
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
func @unsupported_attribute() {
|
||||
// expected-error @+1 {{unsupported 'value' attribute: "" : index}}
|
||||
%0 = constant "" : index
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue