Skip to content

null analysis #2

@rosefromthedead

Description

@rosefromthedead

It would be good to avoid wrapping every pointer in Option unless the C side had explicit null checks or assignments. The checks are currently represented as .is_null(), but none of our benchmarks seem to contain any null assignments. A naive way of doing it might be easy to implement, but to be rigorous we'd need to consider control flow to catch cases like this:

fn f() -> *mut T {
    let mut p = ...;
    if p.is_null() {
        p = malloc(...);
    }
    return p;
}

here, p could be null at the start of the function, but we can show that it isn't null when it's returned, so it's best to conclude that this function can't return null. It seems likely to me that SSA would help with this. I'll have a go at implementing this, but any thoughts on it are welcome

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions