This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump][test] Improve testing of some switches #2
ClosedPublic

Authored by jhenderson on May 16 2019, 3:25 AM.

Details

Summary

This patch focuses on adding additional testing for the --source switch. For reference, the source-interleave-x86_64.ll has been split into two parts - the input (shared with the other tests) and the test itself.

Diff Detail

Repository
rL LLVM

Event Timeline

jhenderson created this revision.May 16 2019, 3:25 AM
MaskRay added inline comments.May 18 2019, 3:16 AM
test/tools/llvm-objdump/X86/Inputs/source-interleave.ll
2 ↗(On Diff #199776)

Rename..

test/tools/llvm-objdump/X86/source-interleave-missing-source.test
5 ↗(On Diff #199776)

I wanted to ask whether sed -e 's,SRC_COMPDIR,%p,' works on Windows, if it works, we don't need to use %/p.

In a *nix shell, printf %s '\a\b' => \a\b

jhenderson marked 2 inline comments as done.May 20 2019, 3:47 AM
jhenderson added inline comments.
test/tools/llvm-objdump/X86/Inputs/source-interleave.ll
2 ↗(On Diff #199776)

Rename which bit? I can't rename the file to two different files (as things stand I've renamed X86/source-interleave-x86_64.ll to X86/source-interleave-x86_64.test). Also, my patch creation process may sometimes mess things up (sometimes it thinks things are modified, not added for example), but the final commit will actually be a rename.

If you're referring to renaming "source-interleave-x86_64.c" to something else, then no, because that needs to point at the .c file that this .ll was generated from (and that is unchanged).

test/tools/llvm-objdump/X86/source-interleave-missing-source.test
5 ↗(On Diff #199776)

%p doesn't work in that string, because it becomes something like "C:\test\directory" and the \t and \d get interpreted as escape characters. See also https://reviews.llvm.org/D61856.

Note: I do most of my development on Windows, so I'll pick up issues like that.

I do not feel I am right person to accept that, would be nice to have someone else to take a look.
But I read carefully all the test cases and what is going on looks reasonable to me, so I think it is correct.
Minor question is inlined.

test/tools/llvm-objdump/X86/source-interleave-invalid-source.test
5 ↗(On Diff #199776)

May be silly question, but what if it is lower? I.e. s,line: 7,line: -1,g?
Does it makes sence to test it?

jhenderson marked an inline comment as done.May 20 2019, 7:53 AM
jhenderson added inline comments.
test/tools/llvm-objdump/X86/source-interleave-invalid-source.test
5 ↗(On Diff #199776)

I don't think so. That sounds like it's testing llc's handling of weird looking data. I'll experiment though to see what it actually ends up as.

MaskRay added inline comments.May 20 2019, 8:45 AM
test/tools/llvm-objdump/X86/Inputs/source-interleave.ll
2 ↗(On Diff #199776)

Oh I thought you renamed source-interleave-x86_64.c to source-interleave.c. If the C source hasn't been renamed, why do you rename the .ll file?

17 ↗(On Diff #199776)

I don't know how you feel about it, but I think these functions can just be empty. That is sufficient to emit debug info entries which will be used by the line table parser.

test/tools/llvm-objdump/X86/source-interleave-missing-source.test
5 ↗(On Diff #199776)

That test said \t didn't work in double quotes. If \t doesn't work in single quotes, either, %/p seems fine.

rupprecht accepted this revision.May 21 2019, 5:57 PM
rupprecht added inline comments.
test/tools/llvm-objdump/X86/Inputs/source-interleave.ll
17 ↗(On Diff #199776)

I think having the real implementation (even if it's relatively short) will be a more realistic test of interleaved source. But maybe I don't understand your comment?

41 ↗(On Diff #199776)

Mind adding a comment here (or maybe at the top) that tests using this file need to run sed to fix this? Took me longer than I would like to admit to realize that.

test/tools/llvm-objdump/X86/source-interleave-x86_64.test
1 ↗(On Diff #199776)

Change ; to # for the test now that it doesn't have to parse as a .ll file

This revision is now accepted and ready to land.May 21 2019, 5:57 PM
MaskRay added inline comments.May 22 2019, 5:41 AM
test/tools/llvm-objdump/X86/Inputs/source-interleave.ll
17 ↗(On Diff #199776)

I ask because I find these irrelevant lines make the test hard to read. I am fine if you decide to keep the status quo.

What is important here is the source, the IR is just to provide debug information. If the function body is empty, we may argue that after optimizations the function is known to be empty.....

jhenderson marked 10 inline comments as done.

Address some review comments (discussed inline). Change a %t to %/t, and tidy up a couple of double spaces.

test/tools/llvm-objdump/X86/Inputs/source-interleave.ll
2 ↗(On Diff #199776)

I can name it source-interleave-x86_64.ll if you prefer. It's in a different directory to where the code comes from, so it's still a new file.

17 ↗(On Diff #199776)

I'm okay doing this, but maybe in a separate patch, since that keeps the diffs cleaner, and shouldn't impact the new tests. By the way, the original contributor was specifically asked to produce the .ll from the .c file for the original test.

41 ↗(On Diff #199776)

I've added the comment to the top of the file.

test/tools/llvm-objdump/X86/source-interleave-invalid-source.test
5 ↗(On Diff #199776)

As I suspected, llc emits an error if passed a negative number.

test/tools/llvm-objdump/X86/source-interleave-missing-source.test
5 ↗(On Diff #199776)

I've tried single-quotes, and it doesn't work unfortunately.

@MaskRay, are you happy with this as is, or would you like any further changes in this patch?

MaskRay accepted this revision.May 22 2019, 9:13 AM

I just wanted to ask if you want to make the test easier to read (making the function body empty), or to make it realistic (no change). I'm happy with either choice.

jhenderson retitled this revision from [llvm-objdump]Improve testing of some switches #2 to [llvm-objdump][test] Improve testing of some switches #2.May 23 2019, 2:27 AM
This revision was automatically updated to reflect the committed changes.

I just wanted to ask if you want to make the test easier to read (making the function body empty), or to make it realistic (no change). I'm happy with either choice.

I started looking at simplifying the test input, but quickly realised that I'm not familiar enough with the format, and couldn't get it to work easily. As there isn't a desperate need to change things, I'm inclined to leave it as is, although if others want to make that change, I'm not opposed to it.

This caused lit failures for somebody who had 'main' in their directory tree, so I am changing the --implicit-check-not=main lines into --implicit-check-not='main()'. Let me know if anybody thinks this is a bad idea.

This caused lit failures for somebody who had 'main' in their directory tree, so I am changing the --implicit-check-not=main lines into --implicit-check-not='main()'. Let me know if anybody thinks this is a bad idea.

Committed in rL361621.

llvm/trunk/test/tools/llvm-objdump/X86/source-interleave-relative-paths.test