mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 16:47:21 +03:00
Fix all optimization-inhibiting integer-to-pointer casts
Following from PR #2481, we replace all integer-to-pointer casts [which hide pointer provenance information (and thus inhibit optimizations)](https://clang.llvm.org/extra/clang-tidy/checks/performance/no-int-to-ptr.html) with equivalent operations that preserve this information. I have enabled the corresponding clang-tidy check in our static analysis CI so that we do not get bitten by this again in the future.
This commit is contained in:
parent
4827bb17bd
commit
3e82f357bb
27 changed files with 116 additions and 66 deletions
|
|
@ -181,9 +181,9 @@ base_extent_bump_alloc_helper(edata_t *edata, size_t *gap_size, size_t size,
|
|||
|
||||
*gap_size = ALIGNMENT_CEILING((uintptr_t)edata_addr_get(edata),
|
||||
alignment) - (uintptr_t)edata_addr_get(edata);
|
||||
ret = (void *)((uintptr_t)edata_addr_get(edata) + *gap_size);
|
||||
ret = (void *)((byte_t *)edata_addr_get(edata) + *gap_size);
|
||||
assert(edata_bsize_get(edata) >= *gap_size + size);
|
||||
edata_binit(edata, (void *)((uintptr_t)edata_addr_get(edata) +
|
||||
edata_binit(edata, (void *)((byte_t *)edata_addr_get(edata) +
|
||||
*gap_size + size), edata_bsize_get(edata) - *gap_size - size,
|
||||
edata_sn_get(edata));
|
||||
return ret;
|
||||
|
|
@ -291,7 +291,7 @@ base_block_alloc(tsdn_t *tsdn, base_t *base, ehooks_t *ehooks, unsigned ind,
|
|||
block->next = NULL;
|
||||
assert(block_size >= header_size);
|
||||
base_edata_init(extent_sn_next, &block->edata,
|
||||
(void *)((uintptr_t)block + header_size), block_size - header_size);
|
||||
(void *)((byte_t *)block + header_size), block_size - header_size);
|
||||
return block;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue