Skip to content

Commit 559e6c5

Browse files
WillFroomkrishna2803
authored andcommitted
[MLIR] Add test to check that we don't reinit after running pass again (llvm#151963)
Following on from llvm#150948
1 parent 170352f commit 559e6c5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mlir/test/CAPI/pass.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,23 @@ void testExternalPass(void) {
486486
exit(EXIT_FAILURE);
487487
}
488488

489+
// Run the pass again and confirm that the initializeCallCount is still 1.
490+
MlirLogicalResult second_success = mlirPassManagerRunOnOp(pm, module);
491+
if (mlirLogicalResultIsFailure(second_success)) {
492+
fprintf(stderr, "Unexpected failure running external pass.\n");
493+
exit(EXIT_FAILURE);
494+
}
495+
496+
if (userData.initializeCallCount != 1) {
497+
fprintf(stderr, "Expected initializeCallCount to be 1\n");
498+
exit(EXIT_FAILURE);
499+
}
500+
501+
if (userData.runCallCount != 2) {
502+
fprintf(stderr, "Expected runCallCount to be 2\n");
503+
exit(EXIT_FAILURE);
504+
}
505+
489506
mlirPassManagerDestroy(pm);
490507

491508
if (userData.destructCallCount != userData.constructCallCount) {

0 commit comments

Comments
 (0)