@@ -276,6 +276,7 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
276
276
if (!irdlFile.empty () && failed (loadIRDLDialects (irdlFile, roundtripContext)))
277
277
return failure ();
278
278
279
+ std::string testType = (useBytecode) ? " bytecode" : " textual" ;
279
280
// Print a first time with custom format (or bytecode) and parse it back to
280
281
// the roundtripModule.
281
282
{
@@ -289,16 +290,16 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
289
290
}
290
291
} else {
291
292
op->print (ostream,
292
- OpPrintingFlags ().printGenericOpForm (false ).enableDebugInfo ());
293
+ OpPrintingFlags ().printGenericOpForm ().enableDebugInfo ());
293
294
}
294
295
FallbackAsmResourceMap fallbackResourceMap;
295
296
ParserConfig parseConfig (&roundtripContext, /* verifyAfterParse=*/ true ,
296
297
&fallbackResourceMap);
297
298
roundtripModule =
298
299
parseSourceString<Operation *>(ostream.str (), parseConfig);
299
300
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 " ;
302
303
return failure ();
303
304
}
304
305
}
@@ -317,21 +318,22 @@ static LogicalResult doVerifyRoundTrip(Operation *op,
317
318
}
318
319
if (reference != roundtrip) {
319
320
// 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 " ;
324
327
}
325
328
326
329
return success ();
327
330
}
328
331
329
332
static LogicalResult doVerifyRoundTrip (Operation *op,
330
333
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));
335
337
}
336
338
337
339
// / Perform the actions on the input file indicated by the command line flags
0 commit comments