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

Fact propagation fails when combined with drop, panics, and memory swaps #114533

Open
SUPERCILEX opened this issue Aug 6, 2023 · 0 comments
Open
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SUPERCILEX
Copy link
Contributor

use std::mem;

struct Foo(Vec<u32>);

impl Drop for Foo {
    fn drop(&mut self) {
        if self.0.is_empty() {
            return;
        }

        let v = mem::take(&mut self.0);

        panic!("dead");
    }
}

pub fn foo() {
    let a = Foo(Vec::new());
    unsafe {unknown(9);}
}

extern "Rust" {
    fn unknown(x: i32) -> bool;
}

https://rust.godbolt.org/z/ra7bj7zf1

Related issue: #114532. Notice that in this case drop is called before ret so this code can't be eliminated yet (I think).

@SUPERCILEX SUPERCILEX added the C-bug Category: This is a bug. label Aug 6, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 6, 2023
@Noratrieb Noratrieb added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-slow Issue: Problems and improvements with respect to performance of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants