@@ -276,6 +276,7 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
276276 if (!irdlFile.empty () && failed (loadIRDLDialects (irdlFile, roundtripContext)))
277277 return failure ();
278278
279+ std::string testType = (useBytecode) ? " bytecode" : " textual" ;
279280 // Print a first time with custom format (or bytecode) and parse it back to
280281 // the roundtripModule.
281282 {
@@ -289,16 +290,16 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
289290 }
290291 } else {
291292 op->print (ostream,
292- OpPrintingFlags ().printGenericOpForm (false ).enableDebugInfo ());
293+ OpPrintingFlags ().printGenericOpForm ().enableDebugInfo ());
293294 }
294295 FallbackAsmResourceMap fallbackResourceMap;
295296 ParserConfig parseConfig (&roundtripContext, /* verifyAfterParse=*/ true ,
296297 &fallbackResourceMap);
297298 roundtripModule =
298299 parseSourceString<Operation *>(ostream.str (), parseConfig);
299300 if (!roundtripModule) {
300- op->emitOpError ()
301- << " failed to parse bytecode back, cannot verify round-trip.\n " ;
301+ op->emitOpError () << " failed to parse " << testType
302+ << " content back, cannot verify round-trip.\n " ;
302303 return failure ();
303304 }
304305 }
@@ -317,21 +318,22 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
317318 }
318319 if (reference != roundtrip) {
319320 // TODO implement a diff.
320- return op->emitOpError () << " roundTrip testing roundtripped module differs "
321- " from reference:\n <<<<<<Reference\n "
322- << reference << " \n =====\n "
323- << roundtrip << " \n >>>>>roundtripped\n " ;
321+ return op->emitOpError ()
322+ << testType
323+ << " roundTrip testing roundtripped module differs "
324+ " from reference:\n <<<<<<Reference\n "
325+ << reference << " \n =====\n "
326+ << roundtrip << " \n >>>>>roundtripped\n " ;
324327 }
325328
326329 return success ();
327330}
328331
329332static LogicalResult doVerifyRoundTrip (Operation *op,
330333 const MlirOptMainConfig &config) {
331- // Textual round-trip isn't fully robust at the moment (for example implicit
332- // terminator are losing location informations).
333-
334- return doVerifyRoundTrip (op, config, /* useBytecode=*/ true );
334+ auto txtStatus = doVerifyRoundTrip (op, config, /* useBytecode=*/ false );
335+ auto bcStatus = doVerifyRoundTrip (op, config, /* useBytecode=*/ true );
336+ return success (succeeded (txtStatus) && succeeded (bcStatus));
335337}
336338
337339// / Perform the actions on the input file indicated by the command line flags
0 commit comments