I've finally managed to bring my backend to a minimally working form. I can
compile three small examples with arithmetic operations, branches and phi
operations. However, there surely is a lot of omissions and bugs.
How do I test a backend. For obvious reasons, I'd prefer a number of really
small tests, to make debugging easier. I see some number of such small tests
in "test/Feature" directory, but there's no Makefile, so I don't know how
they are run, and most of the tests don't even have "main" function, so I
don't know if they are supposed to be run. Any suggestions?
The makefile for the feature tests is in the directory above. Simply:
cd ~/llvm/test
make Feature.t
This works for the regression tests to:
make Regression.t
The tests are run QMTest which just "knows" what to do with the test
file. In many cases there is a RUN: line which instructs the test
harness how to run the test.
The makefile for the feature tests is in the directory above. Simply:
cd ~/llvm/test
make Feature.t
This works for the regression tests to:
make Regression.t
Thanks,
The tests are run QMTest which just "knows" what to do with the test
file. In many cases there is a RUN: line which instructs the test
harness how to run the test.
In fact, I've already tried to run the tests with QMTest, bypassing Makefiles,
but I get numerous error in QMTest/llvmdb.py. It appears the file was written
against older version of QMTest (I have 2.1.2 here). I've made some attempt
to port to current QMTest, but haven't finished yet.
The makefile for the feature tests is in the directory above. Simply:
cd ~/llvm/test
make Feature.t
This works for the regression tests to:
make Regression.t
The tests are run QMTest which just "knows" what to do with the test
file. In many cases there is a RUN: line which instructs the test
harness how to run the test.
The QMTest tests are generally small LLVM code snippets that we manipulate and then examine for correctness. You can add your own tests to llvm/test/Regression/CodeGen/<platform> if you want to write small, articifical test cases where you know what to check for. For example, see llvm/test/Regression/CodeGen/X86/2004-02-12-Memcpy.llx.
QMTest tests are not full programs, so the code is never executed and tested for correctness.
If you want simple C programs to compile and test with your code generator, I'd recommend the tests in llvm/test/Programs/SingleSource. The tests in llvm/test/Programs are all complete programs that can be compiled and executed. You can use them to compare your code generator results with that of the native compiler.
As John mentioned, the test/Programs/SingleSource directory is the place
to start. I would recommend looking at .../Regressions/C .../UnitTests
and .../Benchmarks/Shootout. When stuff is basically sorta working, you
can move up to the "big" ones like Benchmarks/Dhyrstone
Also, one of the really nice things of the test/Programs hierarchy is that
it has a lot of debugging functionality built in. In particular, if a
program (say test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c)
crashes or miscompiles with your code generator, you can go into that
directory and say:
make Output/2003-05-31-CastToBool.bugpoint-llc
... and bugpoint will autoreduce the testcase down to something that is
hopefully trivially small for you to work with.