Skip to content
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

Calls to C variadic functions are inlined by MIR inliner #78859

Closed
tmiasko opened this issue Nov 7, 2020 · 0 comments · Fixed by #78966
Closed

Calls to C variadic functions are inlined by MIR inliner #78859

tmiasko opened this issue Nov 7, 2020 · 0 comments · Fixed by #78966
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. F-c_variadic `#![feature(c_variadic)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tmiasko
Copy link
Contributor

tmiasko commented Nov 7, 2020

#![feature(c_variadic)]

fn main() {
    let s = unsafe { sum(4u32, 4u32, 30u32, 200u32, 1000u32) };
    assert_eq!(s, 1234);
}

#[no_mangle]
#[inline(always)]
pub unsafe extern "C" fn sum(n: u32, mut vs: ...) -> u32 {
    let mut s = 0;
    let mut i = 0;
    while i != n {
        s += vs.arg::<u32>();
        i += 1;
    }
    s
}
$ rustc v.rs -Zmir-opt-level=2
error: internal compiler error: compiler/rustc_middle/src/mir/tcx.rs:84:25: deref projection of non-dereferenceable ty PlaceTy { ty: u32, variant_index: None }

@rustbot modify labels: +A-mir-opt, +A-mir-opt-inlining

@tmiasko tmiasko added the C-bug Category: This is a bug. label Nov 7, 2020
@rustbot rustbot added A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining labels Nov 7, 2020
@jonas-schievink jonas-schievink added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 7, 2020
@camelid camelid added the F-c_variadic `#![feature(c_variadic)]` label Nov 9, 2020
m-ou-se added a commit to m-ou-se/rust that referenced this issue Nov 12, 2020
Never inline C variadics, cold functions, functions with incompatible attributes ...

... and fix generator inlining.

Closes rust-lang#67863.
Closes rust-lang#78859.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 13, 2020
Never inline C variadics, cold functions, functions with incompatible attributes ...

... and fix generator inlining.

Closes rust-lang#67863.
Closes rust-lang#78859.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 13, 2020
Never inline C variadics, cold functions, functions with incompatible attributes ...

... and fix generator inlining.

Closes rust-lang#67863.
Closes rust-lang#78859.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 14, 2020
Never inline C variadics, cold functions, functions with incompatible attributes ...

... and fix generator inlining.

Closes rust-lang#67863.
Closes rust-lang#78859.
@bors bors closed this as completed in 6be44ed Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining C-bug Category: This is a bug. F-c_variadic `#![feature(c_variadic)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants