This is an archive of the discontinued LLVM Phabricator instance.

[Utils] Do not remove comments in llc test script
ClosedPublic

Authored by sebastian-ne on Apr 26 2021, 11:03 AM.

Details

Summary

When checking if two prefixes can be merged for a function,
update_llc_test_checks.py removed IR comments before comparing
llc outputs of different RUN lines.
This means, if one RUN line emited lines starting with ';' and another
RUN line emited the same lines except the ones starting with ';', both
RUNs would be merged (if they share a prefix).

However, CHECK-NEXT lines check the comments, otherwise they fail, so
the script should not merge RUNs if they contain different comments.

Diff Detail

Event Timeline

sebastian-ne created this revision.Apr 26 2021, 11:03 AM
sebastian-ne requested review of this revision.Apr 26 2021, 11:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2021, 11:03 AM

I'm trying to understand the functionality you want to achieve. Doesn't using different prefixes avoid merging already? The test does not seem to exercise your extensions.

I'm trying to understand the functionality you want to achieve. Doesn't using different prefixes avoid merging already? The test does not seem to exercise your extensions.

He, that is a good point, it was my intention to add a common prefix to the test. I added that and checked that the test now fails without the script changes.

(It will end up merging the output for the two run lines. Running FileCheck will then fail for the GFX9-O0 case, because the comments are missing in the CHECK-NEXT lines.)

friendly ping for review

foad added inline comments.May 7 2021, 2:37 AM
llvm/utils/UpdateTestChecks/common.py
271

It seems like most of the "arg name scrubbing" that this function does is not relevant for asm? Perhaps update_llc_test_checks could use a much much simpler form of this function instead?

foad added a comment.May 7 2021, 2:46 AM

Also, I don't understand why it would be OK for non-asm dialects to remove a whole-line comment. Maybe the problem is that SCRUB_IR_COMMENT should remove a trailing comment only, but not completely delete a whole-line comment?

I guess it is fine for MIR tests because they only use CHECK lines instead of CHECK-NEXT lines.

foad added a comment.May 7 2021, 3:10 AM

I guess it is fine for MIR tests because they only use CHECK lines instead of CHECK-NEXT lines.

In add_checks() it looks like non-asm dialects use CHECK-NEXT normally, but CHECK after one or more blank lines.

It seems like most of the "arg name scrubbing" that this function does is not relevant for asm? Perhaps update_llc_test_checks could use a much much simpler form of this function instead?

You’re right, seems like D68819 added it and it is meant for IR test. For args_and_sig, it is still done (whatever that contains in llc tests), but for the body, the scrubbing with these regexes is skipped: https://github.com/llvm/llvm-project/blob/bbcbf21ae60c928e07dde6a1c468763b3209d1e6/llvm/utils/UpdateTestChecks/common.py#L679-L687
So, I hope it works if we do the same in this check function as when emitting the check lines.

Maybe the problem is that SCRUB_IR_COMMENT should remove a trailing comment only, but not completely delete a whole-line comment?

Probably, that is a different problem and should be fixed in a different patch (if is_asm is true, the regexes are not applied at all; IR comments are left in place for llc tests). The problem is that \s in the regex also matches—and removes—newlines. I guess the most difficult part is coming up with a testcase.

Sorry, it took me a while to look at this again.

Fix missing 'not' in comment.

friendly ping for review

friendly ping for review

foad accepted this revision.Jul 29 2021, 2:35 AM

Looks OK to me, thanks.

This revision is now accepted and ready to land.Jul 29 2021, 2:35 AM
This revision was automatically updated to reflect the committed changes.