-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Revamp codegen tests to check IR quality instead of quantity #25762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
Very cool. |
Looks good to me! I'll refrain from r+'ing though since it seems like @nikomatsakis or someone should get the chance to see it first. |
Amazing! I'm really looking forward to turning back on these kinds of tests. A few questions:
|
It would probably be a good idea to let different tests decide whether or not they want to pass As for brittleness, that really depends on how specific the tests get. For the initial couple in this pull we're only checking things like argument attributes ( |
@luqmana hm yeah makes sense about
True, I suspect it wouldn't be too hard to upgrade. I'm mostly just worried about multiple LLVM versions but we can always deal with that later as well! |
That's to make sure we actually check what we emit and not what LLVM can deduce. Also, the way the tests are written, the deduced flags would actually make them fail. The tests should run by default, but I'll test that tomorrow to make sure. I also forgot to remove some remaining code from the old codegen test setup that checks for clang. Will fix that tomorrow, too. |
Ah of course!
Perfect! r=me with those minor changes and/or validations. |
The current codegen tests only compare IR line counts between similar rust and C programs, the latter getting compiled with clang. That looked like a good idea back then, but actually things like lifetime intrinsics mean that less IR isn't always better, so the metric isn't really helpful. Instead, we can start doing tests that check specific aspects of the generated IR, like attributes or metadata. To do that, we can use LLVM's FileCheck tool which has a number of useful features for such tests. To start off, I created some tests for a few things that were recently added and/or broken.
The current codegen tests only compare IR line counts between similar rust and C programs, the latter getting compiled with clang. That looked like a good idea back then, but actually things like lifetime intrinsics mean that less IR isn't always better, so the metric isn't really helpful. Instead, we can start doing tests that check specific aspects of the generated IR, like attributes or metadata. To do that, we can use LLVM's FileCheck tool which has a number of useful features for such tests. To start off, I created some tests for a few things that were recently added and/or broken.
The current codegen tests only compare IR line counts between similar
rust and C programs, the latter getting compiled with clang. That looked
like a good idea back then, but actually things like lifetime intrinsics
mean that less IR isn't always better, so the metric isn't really
helpful.
Instead, we can start doing tests that check specific aspects of the
generated IR, like attributes or metadata. To do that, we can use LLVM's
FileCheck tool which has a number of useful features for such tests.
To start off, I created some tests for a few things that were recently
added and/or broken.