-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Tell LLVM about impossible niche tags #139098
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
WaffleLapkin marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
|
||
#![crate_type = "lib"] | ||
|
||
// This directly tests what we emit for these matches, rather than what happens | ||
// after optimization, so it doesn't need to worry about extra flags on the | ||
// instructions and is less susceptible to being broken on LLVM updates. | ||
|
||
// CHECK-LABEL: @option_match | ||
#[no_mangle] | ||
pub fn option_match(x: Option<i32>) -> u16 { | ||
|
@@ -103,10 +107,22 @@ pub fn option_ordering_match(x: Option<Ordering>) -> char { | |
// CHECK-LABEL: @option_nonzero_match( | ||
#[no_mangle] | ||
pub fn option_nonzero_match(x: Option<std::num::NonZero<u16>>) -> u16 { | ||
// CHECK: %[[OUT:.+]] = alloca [2 x i8] | ||
|
||
// CHECK: %[[IS_NONE:.+]] = icmp eq i16 %x, 0 | ||
// CHECK: %[[OPT_DISCR:.+]] = select i1 %[[IS_NONE]], i64 0, i64 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to not emit a select if it's equivalent to zext? Or would that be pointless? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if it's really worth it vs just letting LLVM do it for us. (And this one would need to flip the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I originally thought about widen/trunc too, but figured that this is just multiple parts of our code assuming the type. |
||
// CHECK: %[[OPT_DISCR_T:.+]] = trunc nuw i64 %[[OPT_DISCR]] to i1 | ||
// CHECK: br i1 %[[OPT_DISCR_T]], label %[[BB_SOME:.+]], label %[[BB_NONE:.+]] | ||
|
||
// CHECK: [[BB_SOME]]: | ||
// CHECK: store i16 987, ptr %[[OUT]] | ||
|
||
// CHECK: [[BB_NONE]]: | ||
// CHECK: store i16 123, ptr %[[OUT]] | ||
|
||
// CHECK: %[[RET:.+]] = load i16, ptr %[[OUT]] | ||
// CHECK: ret i16 %[[RET]] | ||
|
||
match x { | ||
None => 123, | ||
Some(_) => 987, | ||
|
Uh oh!
There was an error while loading. Please reload this page.