-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix codegen of uninhabited PassMode::Indirect return types.
Add codegen test for uninhabited PassMode::Indirect return types.
- Loading branch information
Showing
2 changed files
with
49 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// See https://github.com/rust-lang/rust/issues/135802 | ||
|
||
#![crate_type = "lib"] | ||
|
||
enum Void {} | ||
|
||
// Should be ABI-compatible with T, but wasn't prior to the PR adding this test. | ||
#[repr(transparent)] | ||
struct NoReturn<T>(T, Void); | ||
|
||
// Returned by invisible reference (in most ABIs) | ||
#[allow(dead_code)] | ||
struct Large(u64, u64, u64); | ||
|
||
extern "Rust" { | ||
fn opaque() -> NoReturn<Large>; | ||
fn opaque_with_arg(rsi: u32) -> NoReturn<Large>; | ||
} | ||
|
||
// CHECK-LABEL: @test_uninhabited_ret_by_ref | ||
#[no_mangle] | ||
pub fn test_uninhabited_ret_by_ref() { | ||
// CHECK: %_1 = alloca [24 x i8], align {{8|4}} | ||
// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_1) | ||
// CHECK-NEXT: call void @opaque(ptr noalias nocapture noundef nonnull sret([24 x i8]) align {{8|4}} dereferenceable(24) %_1) #2 | ||
// CHECK-NEXT: unreachable | ||
unsafe { | ||
opaque(); | ||
} | ||
} | ||
|
||
// CHECK-LABEL: @test_uninhabited_ret_by_ref_with_arg | ||
#[no_mangle] | ||
pub fn test_uninhabited_ret_by_ref_with_arg(rsi: u32) { | ||
// CHECK: %_2 = alloca [24 x i8], align {{8|4}} | ||
// CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %_2) | ||
// CHECK-NEXT: call void @opaque_with_arg(ptr noalias nocapture noundef nonnull sret([24 x i8]) align {{8|4}} dereferenceable(24) %_2, i32 noundef %rsi) #2 | ||
// CHECK-NEXT: unreachable | ||
unsafe { | ||
opaque_with_arg(rsi); | ||
} | ||
} |