Marcus Johnson via llvm-dev
2017-Nov-27 17:22 UTC
[llvm-dev] Is it ok to allocate > half of address space?
I'm not a compiler writer, but what about embedded devices with a very small address space? This just seems like an arbitrary limit for no real reason, especially when it's "anchored" by the address space which could be absolutely anything.
David Chisnall via llvm-dev
2017-Nov-28 09:53 UTC
[llvm-dev] Is it ok to allocate > half of address space?
On 27 Nov 2017, at 17:22, Marcus Johnson via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > I'm not a compiler writer, but what about embedded devices with a very small address space? > > This just seems like an arbitrary limit for no real reason, especially when it's "anchored" by the address space which could be absolutely anything.It’s pretty uncommon to find embedded devices where this is a problem. It’s basically only an issue on 16-bit microcontrollers with more than 32KB of memory. 32-bit (e.g. ARM M-profile) microcontrollers are unlikely to have more than the 2GB of RAM required for this to be an issue. Even if LLVM allows it, it’s only useful if the source language is not C, where the size of an object is size_t and the difference between two pointers is ptrdiff_t. If size_t is unsigned and ptrdiff_t is the signed version of the same size type[1] then pointer subtraction of the end and the start of any object larger than half of the range of size_t will give very surprising results. David [1] C requires that size_t be unsigned and ptrdiff_t be signed, but does not require them to be the same size. It would be possible to have a C implementation with a larger ptrdiff_t than size_t, but I’ve never seen one.