This is an archive of the discontinued LLVM Phabricator instance.

[FileCheck] Allow literal '['s before "[[var...]]"
ClosedPublic

Authored by foad on Jan 12 2022, 7:22 AM.

Details

Summary

Change FileCheck to accept patterns like "[[[var...]]" and treat the
excess open brackets at the start as literals.

This makes the patterns for matching assembler output with literal
brackets much cleaner. For example an AMDGPU pattern that used to be
written like:

buffer_store_dwordx2 v{{\[}}[[LO]]:[[HI]]{{\]}}

can now be:

buffer_store_dwordx2 v[[[LO]]:[[HI]]]

(Even before this patch the final close bracket did not need to be
wrapped in {{}}, but people tended to do it anyway for symmetry.)

This does not introduce any ambiguity since "[[" was always followed by
an identifier or '@' or '#', so "[[[" was always an error.

I've included a few test updates in this patch just for illustration and
testing. There are a couple of hundred tests that could be updated as a
follow up, mostly in test/CodeGen/.

Diff Detail

Event Timeline

foad created this revision.Jan 12 2022, 7:22 AM
foad requested review of this revision.Jan 12 2022, 7:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2022, 7:22 AM

Could you add a new testcase somewhere in llvm/test/FileCheck? Thanks!

llvm/lib/FileCheck/FileCheck.cpp
1194

Why the special treatment for {{ here since only the [[[ case is handled above?

foad added inline comments.Jan 12 2022, 7:55 AM
llvm/lib/FileCheck/FileCheck.cpp
1194

Only for consistency and/or efficiency. At this point we know that PatternStr does not start with {{ since it was handled above, so there is no need to check for it at offset 0. And I found it easier to understand the code if both calls to find look the same.

foad updated this revision to Diff 399332.Jan 12 2022, 8:00 AM

Add a FileCheck test.

foad added a reviewer: eliben.Jan 12 2022, 8:00 AM
thopre accepted this revision.Jan 12 2022, 1:50 PM
thopre added inline comments.
llvm/lib/FileCheck/FileCheck.cpp
1194

Fair enough

This revision is now accepted and ready to land.Jan 12 2022, 1:50 PM
This revision was landed with ongoing or failed builds.Jan 13 2022, 1:52 AM
This revision was automatically updated to reflect the committed changes.