File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
llvm/include/llvm/Support Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -149,21 +149,21 @@ class BumpPtrAllocatorImpl
149
149
// Keep track of how many bytes we've allocated.
150
150
BytesAllocated += Size;
151
151
152
- size_t Adjustment = offsetToAlignedAddr (CurPtr, Alignment);
153
- assert (Adjustment + Size >= Size && " Adjustment + Size must not overflow" );
152
+ char *AlignedPtr = reinterpret_cast <char *>(alignAddr (CurPtr, Alignment));
154
153
155
154
size_t SizeToAllocate = Size;
156
155
#if LLVM_ADDRESS_SANITIZER_BUILD
157
156
// Add trailing bytes as a "red zone" under ASan.
158
157
SizeToAllocate += RedZoneSize;
159
158
#endif
160
159
160
+ char *AllocEndPtr = AlignedPtr + SizeToAllocate;
161
+
161
162
// Check if we have enough space.
162
- if (LLVM_LIKELY (Adjustment + SizeToAllocate <= size_t ( End - CurPtr)
163
+ if (LLVM_LIKELY (AllocEndPtr <= End
163
164
// We can't return nullptr even for a zero-sized allocation!
164
165
&& CurPtr != nullptr )) {
165
- char *AlignedPtr = CurPtr + Adjustment;
166
- CurPtr = AlignedPtr + SizeToAllocate;
166
+ CurPtr = AllocEndPtr;
167
167
// Update the allocation point of this memory block in MemorySanitizer.
168
168
// Without this, MemorySanitizer messages for values originated from here
169
169
// will point to the allocation of the entire slab.
You can’t perform that action at this time.
0 commit comments