This is an archive of the discontinued LLVM Phabricator instance.

BumpPtrAllocator: remove redundant no-slabs-allocated-yet check
ClosedPublic

Authored by hans on Aug 16 2014, 8:01 PM.

Details

Summary

We already handle the no-slabs case when checking whether the current slab is large enough: if no slabs have been allocated, CurPtr and End are both 0. alignPtr(0), will still be 0, and so "if (Ptr + Size <= End)" fails.

I measured a 1.5% speed-up with "perf stat -r10 clang -fsyntax-only -w gcc.c".

The thing I'd like review for is whether "Ptr + Size <= End" is strictly correct. It seems to me that Ptr + Size would often point outside the slab object (especially now when Ptr can be 0), and that comparing that with End would be undefined behaviour. Perhaps we should really be using intptr_t here?

Diff Detail

Repository
rL LLVM

Event Timeline

hans updated this revision to Diff 12587.Aug 16 2014, 8:01 PM
hans retitled this revision from to BumpPtrAllocator: remove redundant no-slabs-allocated-yet check.
hans updated this object.
hans edited the test plan for this revision. (Show Details)
hans added subscribers: Unknown Object (MLST), hansw.
hans closed this revision.Aug 17 2014, 11:40 AM
hans updated this revision to Diff 12591.

Closed by commit rL215841 (authored by @hans).