[llvm-dev] RFC: FileCheck Enhancements

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 13 16:50:03 PDT 2016

On Sep 13, 2016, at 11:16 AM, Vedant Kumar <vsk at apple.com> wrote:
>> Instead of doing this, has anyone considered baking “modes” into Filecheck to support the important clients (e.g. LLVM IR, MC, clang, etc)?  This would mean that a test could just add a “--mode=llvmir” flag to filecheck and get a bunch of baked in patterns, potentially with magic syntax.  Something like this would avoid having to redundantly enter "%[0-9]+” a kajillion times all over the place.
> I hadn't considered adding modes to FileCheck. That seems like it could work
> pretty well.
> Even if that's the route we're going to take, I'd prefer that the FileCheck
> modes simply expose pre-defined patterns instead of introducing magic syntax.
> It would be a shame to have to hack FileCheck to use check patterns for clients
> that aren't LLVM IR, clang, etc.


This is a tradeoff: the more extensible you make filecheck (by introducing ever more complicated DSLs into it) the more esoteric it gets, and the less likely that someone will be able to actually UNDERSTAND a random filecheck invocation that they come across.

The advantage of adding a few hard coded modes to filecheck is that we can have specific standardized solutions to important use cases that the LLVM project has.  FileCheck lives in service of LLVM and its downstream projects, it shouldn’t aspire to be some general tool that needs a DSL.  If a downstream project outside of the LLVM project (e.g. the Rust compiler) wanted its own mode, I think it would be fine to add it, and having a gaggle of modes seems preferable to me than building in a complex DSL for describing named patterns.


More information about the llvm-dev mailing list