This is an archive of the discontinued LLVM Phabricator instance.

Add and link to a testing philosophy document in the developer documentation.
AcceptedPublic

Authored by echristo on Feb 1 2018, 5:17 PM.

Details

Summary

Here's an RFC with patch on documentation explaining the how and why of splitting up tests in the testsuite. Effectively: "Why we don’t emit assembly in the clang testsuite”. It largely elaborates on things already in the developer documentation, but provides a (hopefully) useful example and answers a few questions I've gotten a lot over the years. I wrote this a while back after having to explain for the Nth time why we split things up :)

I've added a few people that probably care about this sort of thing to the review line.

This patch:

  • Adds a link to a testing philosophy document in the developer documentation.
  • Creates a set of explanatory text in another file explaining our philosophy.

Diff Detail

Repository
rL LLVM

Event Timeline

echristo created this revision.Feb 1 2018, 5:17 PM
MatzeB accepted this revision.Feb 1 2018, 5:57 PM
MatzeB added a subscriber: MatzeB.

Thanks for writing this! And LGTM in it's current form already.

I wonder if we should mention unittests here... As the whole llc/opt per-pass testing thing works nice for the majority of our testing. But we still have llvm/unittests for the cases where it doesn't...

docs/TestingPolicy.rst
42

I hate making a simple example more complicated... But I would add -disable-O0-optnone to the clang commandline as many developers get biten by that nowadays.

67–69

as you mention testing a single-pass in opt you should also mention:

`llc -o - a.mir -run-pass=peephole-opt | FileCheck %s`

93–94

see above

109–110

The first sentence seems a bit too much tongue in cheek...

You could also switch the perspective here: "You should make it easy for others to fix your bugs".

This revision is now accepted and ready to land.Feb 1 2018, 5:57 PM
MatzeB added inline comments.Feb 1 2018, 6:01 PM
docs/TestingPolicy.rst
42

Actually maybe using -O3 -mllvm -disable-llvm-optzns -emit-llvm would be the way to go here ?

rnk added inline comments.Feb 1 2018, 6:11 PM
docs/TestingPolicy.rst
36

Is it worth mentioning Sema tests? This is targeted at backend / ISA people, but oftentimes attributes and target features need diagnostic tests. We could mention it briefly here and link to the VerifyDiagnosticConsumer doxygen to explain the other test format: https://clang.llvm.org/doxygen/classclang_1_1VerifyDiagnosticConsumer.html

42

Clang CodeGen RUN lines use -cc1 and look more like:
%clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s

I don't think -disable-llvm-passes / -disable-O0-optnone is necessary. It is necessary when attempting to translate C input to LLVM IR for opt tests in the next step. I'd document it just below here.

Also, I prefer -O1 -Xclang -disable-llvm-passes, i.e. give me lifetime annotations, and any other stuff that Clang would put in the actual "optimizations enabled" IR. I remove them manually when reducing the LLVM IR test case.

126

Personally, I don't like this tool. We end up with golden tests or pixel tests that have to be regenerated when you breathe on the compiler, rather than targeted tests that are constructed so that the relevant code sequence can be easily pattern matched.