- User Since
- Aug 26 2018, 5:22 PM (137 w, 2 d)
Feb 26 2021
Feb 24 2021
Feb 23 2021
Looks good. Thanks for implementing this!
Aug 16 2019
I've filed a bug at https://bugs.llvm.org/show_bug.cgi?id=43021.
Aug 15 2019
Sep 6 2018
(Some emails I sent don't seem to have gotten through.)
Sep 2 2018
@hans So do you think it's okay to go at this point, or do you want more benchmarking?
Aug 31 2018
I think the best solution is to make BumpPtrAllocator::Allocate() consistently return nullptr for zero-size allocations.
Zero-size allocations are already extremely common in the wild; allocating space unnecessarily just imposes a softer
requirement for users to avoid doing it; a guard page is massive overkill; the noalias guarantee seems more valuable;
and users already had to be prepared to occasionally receive nullptr returns for zero-size allocations anyway.
Aug 30 2018
I locally tried adding an assert(Size > 0), but also making Allocate<T>()--which doesn't have any of these attributes--return nullptr for zero elements. This design broke 1,060 tests, mostly in clang but a few in LLVM too. So asserting is going to break a ton of code. (I also tried making it waste some space, but only if you don't go through Allocate<T>()—this worked fine.)
Aug 29 2018
If we end up in a place where you’d still want to avoid empty allocations, then I think we should go back to the previous implementation. Current clients are already receiving duplicate addresses, so this won’t cause any new bugs. We can clearly document the behavior.
Aug 28 2018
Reimplemented to return a unique address for each zero-size allocation.
Zero-size allocations usually happen when an array or string happens to have zero elements. I'm trying to clean up UBSan failures in the Swift compiler, and there are several places where this happens there, such as when an array of code completions has no results. We could guard every call like this with an if/else, or we could wrap llvm::BumpPtrAllocator with something that has the if/else statements, or we could change llvm::BumpPtrAllocator so that it handles zero-size allocations without breaking its own contract.