This is an archive of the discontinued LLVM Phabricator instance.

Create TestReducer pass
ClosedPublic

Authored by msifontes on Jul 8 2020, 1:16 PM.

Details

Summary
  • Create a pass that generates bugs based on trivially defined behavior for the purpose of testing the MLIR Reduce Tool.
  • Implement the functionality inside the pass to crash mlir-opt in the presence of an operation with the name "crashOp".
  • Register the pass as a test pass in the mlir-opt tool.

Diff Detail

Event Timeline

msifontes created this revision.Jul 8 2020, 1:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2020, 1:16 PM
stephenneuendorffer added inline comments.
mlir/test/lib/Reducer/CMakeLists.txt
3

MLIRTestReducer?

mlir/test/lib/Reducer/TestReducer.cpp
17 ↗(On Diff #276538)

test-mlir-reducer?

mlir/test/mlir-reduce/test-reducer-pass.mlir
3

Maybe also want an expected pass without -test-mlir-reduce? And a success without crashOp?

This revision is now accepted and ready to land.Jul 8 2020, 2:32 PM
mehdi_amini added inline comments.Jul 8 2020, 2:42 PM
mlir/test/mlir-reduce/test-reducer-pass.mlir
3

+1

Also, don't use XFAIL: it means that the test is failing.
Instead mark the fact that mlir-opt is intended to crash by running it as RUN: not mlir-opt %s ....

msifontes marked 3 inline comments as done.Jul 8 2020, 3:12 PM
msifontes added inline comments.
mlir/test/mlir-reduce/test-reducer-pass.mlir
3

The initial exit code of the crash is 134. When I use the 'not' keyword it changes it to 1. Should I change the fatal_error call used to produce the crash to an error that produces an exit code of 1?

msifontes updated this revision to Diff 276576.Jul 8 2020, 3:16 PM
  • Modify naming from test reduce to test reducer
  • Add mlir-opt test case without test-mlir-reducer pass
msifontes marked an inline comment as done.Jul 8 2020, 3:21 PM
msifontes updated this revision to Diff 276587.Jul 8 2020, 3:52 PM
msifontes marked an inline comment as not done.

Modify TestReducer.cpp to MLIRTestReducer.cpp

msifontes marked an inline comment as done.Jul 8 2020, 3:53 PM
jpienaar added inline comments.Jul 8 2020, 3:58 PM
mlir/test/lib/Reducer/TestReducer.cpp
9 ↗(On Diff #276538)

Perhaps instead of bugs, error reproducers?

42 ↗(On Diff #276538)

How about just checking for test.crashOp? (e.g., if dialect foo has a crashOp we should ignore it). You should be able to compare the stringref to the constant directly

44 ↗(On Diff #276538)

s/Bug// ?

51 ↗(On Diff #276538)

generating failures ? (depends on if you intend this to just crash or not, else you can say generating crashes)

mehdi_amini added inline comments.Jul 8 2020, 4:09 PM
mlir/test/mlir-reduce/test-reducer-pass.mlir
3

There is something fishy here... not will turn any non 0 exit code into a 0.

msifontes updated this revision to Diff 276632.Jul 8 2020, 9:38 PM
msifontes marked 5 inline comments as done.
  • Modify error to exit with code 1
  • Modify testcase to use the 'not' keyword
  • Change 'bug' wording to 'failure'
jpienaar accepted this revision.Jul 10 2020, 4:41 PM
This revision was automatically updated to reflect the committed changes.