This is an archive of the discontinued LLVM Phabricator instance.

Add a new utility script that helps update very simple regression tests.
AbandonedPublic

Authored by chandlerc on Sep 30 2014, 11:58 AM.

Details

Reviewers
echristo
Summary

This script is currently specific to x86 and limited to use with very
small regression or feature tests using 'llc' and 'FileCheck' in
a reasonably canonical way. It is in no way general purpose or robust at
this point. However, it works quite well for simple examples. Here is
the intended workflow:

  • Make a change that requires updating N test files and M functions' assertions within those files.
  • Stash the change.
  • Update those N test files' RUN-lines to look "canonical"[1].
  • Refresh the FileCheck lines for either the entire file or select functions by running this script.
    • The script will parse the RUN lines and run the 'llc' binary you give it according to each line, collecting the asm.
    • It will then annotate each function with the appropriate FileCheck comments to check every instruction from the start of the first basic block to the last return.
    • There will be numerous cases where the script either fails to remove the old lines, or inserts checks which need to be manually editted, but the manual edits tend to be deletions or replacements of registers with FileCheck variables which are fast manual edits.
    • A common pattern is to have the script insert complete checking of every instruction, and then edit it down to only check the relevant ones.
    • Be careful to do all of these cleanups though! The script is designed to make transferring and formatting the asm output of llc into a test case fast, it is *not* designed to be authoratitive about what constitutes a good test!
  • Commit the nice fresh baseline of checks.
  • Unstash your change and rebuild llc.
  • Re-run script to regenerate the FileCheck annotations
    • Remember to re-cleanup these annotations!!!
  • Check the diff to make sure this is sane, checking the things you expected it to, and check that the newly updated tests actually pass.
  • Profit!

Also, I'm *terrible* at writing Python, and frankly I didn't spend a lot
of time making this script beautiful or well engineered. But it's useful
to me and may be useful to others so I thought I'd send it out.

Diff Detail

Event Timeline

chandlerc updated this revision to Diff 14240.Sep 30 2014, 11:58 AM
chandlerc retitled this revision from to Add a new utility script that helps update very simple regression tests..
chandlerc updated this object.
chandlerc edited the test plan for this revision. (Show Details)
chandlerc added a subscriber: Unknown Object (MLST).
chandlerc updated this revision to Diff 17980.Jan 10 2015, 5:01 PM

Renamed the file to make more sense and a bunch of small fixes I needed while
using this script.

FYI, I'm now bringing up using this script in code reviews. I would really appreciate some review of it. At the least I'd like some acknowledgement that it can be committed in the (quite shoddy) form that it is so that folks can benefit from using it.

I'll get it tomorrow if no one else has.

echristo accepted this revision.Jan 11 2015, 6:38 PM
echristo added a reviewer: echristo.

LGTM with some comments for the regexes and the spot I pointed out otherwise.

Thanks!

-eric

utils/update_llc_test_checks.py
166

Comment this bit?

This revision is now accepted and ready to land.Jan 11 2015, 6:38 PM

Thanks, done and submitted in r225618. Lemme know if the comments don't
work for you. =]

chandlerc abandoned this revision.Apr 6 2016, 10:16 PM