getInt() has a note indicating it is deprecated. The current
behavior with getValue() triggers an assert if the integer is unsigned.
An unsigned integer will hit a verifier failure, but this function is
called on verifier-invalid IR, so needs to be safe against that.
Then that's a documentation bug :-D https://mlir.llvm.org/docs/Dialects/Standard/#stdconstant-constantop says "any type" on everything. A missing check in the verifier as well. I can send those fixes instead (or as well, since the note about removing the use of getInt() is still there)
Yeah that also seemed weird to me
Only one of these codepaths will be hit, so I don't think it matters much
Here's my stack trace (helpfully not symbolized):
@ 0x55e5ce041444 __assert_fail @ 0x55e5cde488f1 mlir::IntegerAttr::getInt() @ 0x55e5cdd9b1fd mlir::ConstantOp::getAsmResultNames() @ 0x55e5cdde46e7 mlir::detail::OpAsmOpInterfaceInterfaceTraits::Model<>::getAsmResultNames() @ 0x55e5cde3c77d (anonymous namespace)::SSANameState::numberValuesInOp() @ 0x55e5cde3cdd6 (anonymous namespace)::SSANameState::numberValuesInRegion() @ 0x55e5cde406ee mlir::detail::AsmStateImpl::AsmStateImpl() @ 0x55e5cde3328a mlir::Operation::print() @ 0x55e5cdebf1c0 mlir::Operation::emitError() @ 0x55e5cdec07c1 mlir::OpState::emitError() @ 0x55e5cddd0a41 mlir::SubTensorOp::verify() @ 0x55e5cddee920 mlir::Op<>::verifyInvariants() @ 0x55e5cdeda2ee (anonymous namespace)::OperationVerifier::verifyOperation() @ 0x55e5cdeda778 (anonymous namespace)::OperationVerifier::verifyOperation() @ 0x55e5cdeda08f mlir::verify() @ 0x55e5cdd7d36b mlir::detail::OpToOpPassAdaptor::run() @ 0x55e5cdd7d7df mlir::detail::OpToOpPassAdaptor::runPipeline() @ 0x55e5cdd7ea14 mlir::detail::OpToOpPassAdaptor::runOnOperationImpl() @ 0x55e5cdd7d336 mlir::detail::OpToOpPassAdaptor::run() @ 0x55e5cdd7d7df mlir::detail::OpToOpPassAdaptor::runPipeline() @ 0x55e5cdd7fee8 mlir::PassManager::run() @ 0x55e5cc6f1ec4 mlir::iree_compiler::translateFromMLIRToVMBytecodeModuleWithFlags()
So I think the issue here is that verification is failing, but then it's printing an (unrelated?) constant as part of that and crashing. Probably that constant would fail verification later, but hasn't been verified yet. So I'm a proponent of still making this change, since less crashing is good and getInt() is deprecated. My understanding is that the pretty printer/parsers were supposed to be allowed to assume the op was verified and the verifier was supposed to print generic IR, but I guess that custom asm names are a special case. That would probably be good to investigate and fix more holistically as well