Giter Site home page Giter Site logo

Comments (5)

nunoplopes avatar nunoplopes commented on June 1, 2024 1

The current LLVM memory model doesn't allow changing the size of objects in place.

Thanks! That's what we wanted to find out. Is this written down anywhere?

I don't recall, but I don't think so. But I can guarantee you that optimizations follow that semantics. And Alive2 too, and these days it is kind of the oracle.

from alive2.

nunoplopes avatar nunoplopes commented on June 1, 2024

The current LLVM memory model doesn't allow changing the size of objects in place.

So, either bar does realloc on the pointer, which is equivalent to freeing it, and thus the load would be UB. Or it doesn't touch the pointer and the load is all fine.

C and C++ don't have object resizing. Or at least not to a point where we may need to model in the IR.
If Rust needs something along these lines, then we need to change LLVM IR's semantics and its optimizations. LLVM is not correct per the semantics you want.

The easiest way would be for Rust to hide the resizing in some function that returns a new pointer, so LLVM can think it's a new object. If that isn't viable (for some reason), then there's a ton of work to be done on LLVM. The Alive2 side is easy FWIW.

from alive2.

RalfJung avatar RalfJung commented on June 1, 2024

The current LLVM memory model doesn't allow changing the size of objects in place.

Thanks! That's what we wanted to find out. Is this written down anywhere?

The easiest way would be for Rust to hide the resizing in some function that returns a new pointer, so LLVM can think it's a new object

That doesn't work, since the entire point of this is to allow old pointers to still be used with the resized allocation. Otherwise we could just use realloc.

from alive2.

RalfJung avatar RalfJung commented on June 1, 2024

What about the other question -- isn't the example an Alive bug since bar might initialize mem[0] to some value and then the source would return that value, but the target would return poison/undef since memory is uninit?

from alive2.

nunoplopes avatar nunoplopes commented on June 1, 2024

What about the other question -- isn't the example an Alive bug since bar might initialize mem[0] to some value and then the source would return that value, but the target would return poison/undef since memory is uninit?

It's a bug, yes.
It's a know problem: Alive2 doesn't havoc local memory blocks on function calls. This requires aligning the allocations in the src & tgt programs, and that stuff isn't implemented yet.

from alive2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.