Llvm test - lit

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:

  1. Create your testing .ll file and put it somewhere under llvm/test/, for instance llvm/test/Transforms/my_test.ll.
  2. Add a comment starting with RUN that specifies the (shell) command to run, for instance, // RUN: opt --passes="mypass" < %s | FileCheck %s
  3. 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