[mlir:Parser] Always splice parsed operations to the end of the parsed block

The current splicing behavior dates back to when all blocks had terminators,
so we would "helpfully" splice before the terminator. This doesn't make sense
anymore, and leads to somewhat unexpected results when parsing multiple
pieces of IR into the same block.

Differential Revision: https://reviews.llvm.org/D135096
This commit is contained in:
River Riddle
2022-10-03 12:26:12 -07:00
parent 5301826fa8
commit 54cdc03dfa
3 changed files with 30 additions and 4 deletions

View File

@@ -1414,8 +1414,7 @@ LogicalResult BytecodeReader::parseIRSection(ArrayRef<uint8_t> sectionData,
// Splice the parsed operations over to the provided top-level block.
auto &parsedOps = moduleOp->getBody()->getOperations();
auto &destOps = block->getOperations();
destOps.splice(destOps.empty() ? destOps.end() : std::prev(destOps.end()),
parsedOps, parsedOps.begin(), parsedOps.end());
destOps.splice(destOps.end(), parsedOps, parsedOps.begin(), parsedOps.end());
return success();
}