Hi,
Can somebody help me in writing testcases for custom passes in LLVM as I could not get proper reference online and I am getting issues while writing and testing tescases.
Assuming you’re writing tests for your Pass locating in-tree, here are the steps:
- Create your testing
.ll
file and put it somewhere underllvm/test/
, for instancellvm/test/Transforms/my_test.ll
. - Add a comment starting with
RUN
that specifies the (shell) command to run, for instance,// RUN: opt --passes="mypass" < %s | FileCheck %s
- Add
CHECK
comments to specifies the desired IR patterns after the code is transformed. Please refer to this document for available checking directive.
If you’re trying to use LIT for out-of-tree Passes that will be a little tricky, here is a tutorial I wrote a long time ago on this matter.
1 Like