-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #59577 - dlrobertson:fix_58881, r=nagisa
Fix LLVM IR generated for C-variadic arguments It is possible to create malformed LLVM IR given variadic arguments that are aggregate types. This occurs due to improper tracking of the current argument in the functions list of arguments. Fixes: #58881
- Loading branch information
Showing
2 changed files
with
23 additions
and
13 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,21 @@ | ||
// compile-flags: -C no-prepopulate-passes | ||
// | ||
// only-x86_64 | ||
// ignore-windows | ||
|
||
#![crate_type = "lib"] | ||
|
||
extern "C" { | ||
fn variadic_fn(_: i32, ...); | ||
} | ||
|
||
#[repr(C)] | ||
struct Foo(u8); | ||
#[repr(C)] | ||
struct Bar(u64, u64, u64); | ||
|
||
// Ensure that emit arguments of the correct type. | ||
pub unsafe fn test_call_variadic() { | ||
// CHECK: call void (i32, ...) @variadic_fn(i32 0, i8 {{.*}}, %Bar* {{.*}}) | ||
variadic_fn(0, Foo(0), Bar(0, 0, 0)) | ||
} |