[compiler-rt] [profile] Perform pointer arithmetic in uintptr_t (PR #118944)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 6 12:55:42 PST 2024
================
@@ -143,49 +137,46 @@ int __llvm_profile_merge_from_buffer(const char *ProfileData,
return 1;
}
- __llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
__llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
- char *SrcCountersStart, *DstCounter;
- const char *SrcCountersEnd, *SrcCounter;
- const char *SrcBitmapStart;
- const char *SrcNameStart;
- const char *SrcValueProfDataStart, *SrcValueProfData;
uintptr_t CountersDelta = Header->CountersDelta;
uintptr_t BitmapDelta = Header->BitmapDelta;
- SrcDataStart =
+ __llvm_profile_data *SrcDataStart =
(__llvm_profile_data *)(ProfileData + sizeof(__llvm_profile_header) +
Header->BinaryIdsSize);
- SrcDataEnd = SrcDataStart + Header->NumData;
- SrcCountersStart = (char *)SrcDataEnd;
- SrcCountersEnd = SrcCountersStart +
- Header->NumCounters * __llvm_profile_counter_entry_size();
- SrcBitmapStart = ptr_add_with_overflow(
- SrcCountersEnd,
- __llvm_profile_get_num_padding_bytes(SrcCountersEnd - SrcCountersStart));
- SrcNameStart = ptr_add_with_overflow(SrcBitmapStart, Header->NumBitmapBytes);
- SrcValueProfDataStart =
+ __llvm_profile_data *SrcDataEnd = SrcDataStart + Header->NumData;
+ uintptr_t SrcCountersStart = (uintptr_t)SrcDataEnd;
----------------
nikic wrote:
SrcDataEnd is a `__llvm_profile_data *` so it does need a cast. I only switched the parts using `(const) char *` to `uintptr_t`.
https://github.com/llvm/llvm-project/pull/118944
More information about the llvm-commits
mailing list