David Greene via llvm-dev
2020-Jul-15 19:11 UTC
[llvm-dev] [RFC] Compiled regression tests.
"Robinson, Paul via llvm-dev" <llvm-dev at lists.llvm.org> writes:>> My use-case is for metadata, where I wanted to do this: >> >> CHECK: %r1 = add %r2, %r3 >> CHECK-SAME: !some-metadata >> CHECK-SAME: !some-other-metadata >> >> where some-metadata and some-other-metadata might be reordered within >> the line (because some unrelated metadata got added to the instruction). >> In other words, all of these should match: >> >> %r1 = add %r2, %r3, !some-metadata !1, !some-other-metadata !2 >> %r1 = add %r2, %r3, !some-other-metadata !1, !some-metadata !2 >> %r1 = add %r2, %r3, !some-other-metadata !1, !some-unrelated-metadata !3, >> !some-metadata !2> > I'd expect the following to do what you want: > > CHECK: %r1 = add %r2, %r3 > CHECK-DAG: !some-metadata > CHECK-DAG: !some-other-metadata > CHECK: {{$}} > > Interestingly, it does not; I filed PR46634 to figure this out.According to that PR this isn't supposed to work. So I don't think we have a solution to do what I want. And CHECK-DAG starts from the end of the previous match, and so can match things on the same line? I didn't expect that given the documentation. -David
Robinson, Paul via llvm-dev
2020-Jul-16 14:12 UTC
[llvm-dev] [RFC] Compiled regression tests.
> -----Original Message----- > From: David Greene <david.greene at hpe.com> > Sent: Wednesday, July 15, 2020 3:11 PM > To: Robinson, Paul <paul.robinson at sony.com>; Michael Kruse > <llvmdev at meinersbur.de>; 'llvm-dev at lists.llvm.org' <llvm- > dev at lists.llvm.org> > Subject: Re: [llvm-dev] [RFC] Compiled regression tests. > > "Robinson, Paul via llvm-dev" <llvm-dev at lists.llvm.org> writes: > > >> My use-case is for metadata, where I wanted to do this: > >> > >> CHECK: %r1 = add %r2, %r3 > >> CHECK-SAME: !some-metadata > >> CHECK-SAME: !some-other-metadata > >> > >> where some-metadata and some-other-metadata might be reordered within > >> the line (because some unrelated metadata got added to the > instruction). > >> In other words, all of these should match: > >> > >> %r1 = add %r2, %r3, !some-metadata !1, !some-other-metadata !2 > >> %r1 = add %r2, %r3, !some-other-metadata !1, !some-metadata !2 > >> %r1 = add %r2, %r3, !some-other-metadata !1, !some-unrelated-metadata > !3, > >> !some-metadata !2 > > > > > I'd expect the following to do what you want: > > > > CHECK: %r1 = add %r2, %r3 > > CHECK-DAG: !some-metadata > > CHECK-DAG: !some-other-metadata > > CHECK: {{$}} > > > > Interestingly, it does not; I filed PR46634 to figure this out. > > According to that PR this isn't supposed to work. So I don't think we > have a solution to do what I want. > > And CHECK-DAG starts from the end of the previous match, and so can > match things on the same line? I didn't expect that given the > documentation. > > -DavidEach CHECK-DAG starts from the end of the previous non-DAG match. CHECK-DAG directives in the same group can't have overlapping matches. Two successive CHECKs of any kind (other than CHECK-NEXT) are allowed to match on the same line; the effect of CHECK-SAME is to *require* that they are on the same line. If you're looking for a way to match two patterns in either order on a single line, I can think of two ways to do that. One depends on having something distinctive that's guaranteed to be on the next line; then you can do CHECK-DAG/CHECK-DAG/CHECK-NEXT. I suspect this is likely to be fragile. If you don't have a distinctive next-line pattern, then I can't think of a multi-directive way to achieve what you want. You'd have to write a regex with alternatives, like this untested attempt: CHECK: {{(!some-metadata.*!other-metadata)|(!other-metadata.*!some-metadata)}} --paulr
Joel E. Denny via llvm-dev
2020-Jul-16 15:15 UTC
[llvm-dev] [RFC] Compiled regression tests.
On Thu, Jul 16, 2020 at 10:12 AM Robinson, Paul via llvm-dev < llvm-dev at lists.llvm.org> wrote:> > > > -----Original Message----- > > From: David Greene <david.greene at hpe.com> > > Sent: Wednesday, July 15, 2020 3:11 PM > > To: Robinson, Paul <paul.robinson at sony.com>; Michael Kruse > > <llvmdev at meinersbur.de>; 'llvm-dev at lists.llvm.org' <llvm- > > dev at lists.llvm.org> > > Subject: Re: [llvm-dev] [RFC] Compiled regression tests. > > > > "Robinson, Paul via llvm-dev" <llvm-dev at lists.llvm.org> writes: > > > > >> My use-case is for metadata, where I wanted to do this: > > >> > > >> CHECK: %r1 = add %r2, %r3 > > >> CHECK-SAME: !some-metadata > > >> CHECK-SAME: !some-other-metadata > > >> > > >> where some-metadata and some-other-metadata might be reordered within > > >> the line (because some unrelated metadata got added to the > > instruction). > > >> In other words, all of these should match: > > >> > > >> %r1 = add %r2, %r3, !some-metadata !1, !some-other-metadata !2 > > >> %r1 = add %r2, %r3, !some-other-metadata !1, !some-metadata !2 > > >> %r1 = add %r2, %r3, !some-other-metadata !1, !some-unrelated-metadata > > !3, > > >> !some-metadata !2 > > > > > > > > I'd expect the following to do what you want: > > > > > > CHECK: %r1 = add %r2, %r3 > > > CHECK-DAG: !some-metadata > > > CHECK-DAG: !some-other-metadata > > > CHECK: {{$}} > > > > > > Interestingly, it does not; I filed PR46634 to figure this out. > > > > According to that PR this isn't supposed to work. So I don't think we > > have a solution to do what I want. > > > > And CHECK-DAG starts from the end of the previous match, and so can > > match things on the same line? I didn't expect that given the > > documentation. > > > > -David > > Each CHECK-DAG starts from the end of the previous non-DAG match. > CHECK-DAG directives in the same group can't have overlapping matches. > Two successive CHECKs of any kind (other than CHECK-NEXT) are allowed > to match on the same line; the effect of CHECK-SAME is to *require* > that they are on the same line. > > If you're looking for a way to match two patterns in either order on > a single line, I can think of two ways to do that. One depends on > having something distinctive that's guaranteed to be on the next line; > then you can do CHECK-DAG/CHECK-DAG/CHECK-NEXT. I suspect this is > likely to be fragile. >It's fragile: the CHECK-NEXT complains if it doesn't match on the line after whichever CHECK-DAG matches later in the input. CHECK-NEXT does not verify that its match is on the line after whichever CHECK-DAG matches earlier in the input. I wish we had a CHECK-DAG-SAME (and CHECK-DAG-NEXT) for cases like these. Joel> > If you don't have a distinctive next-line pattern, then I can't think > of a multi-directive way to achieve what you want. You'd have to write > a regex with alternatives, like this untested attempt: > CHECK: > {{(!some-metadata.*!other-metadata)|(!other-metadata.*!some-metadata)}} > > --paulr > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200716/cc893153/attachment.html>