[PATCH] D104745: [llvm-cov] Enforce alignment of function records
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 22 23:19:26 PDT 2021
serge-sans-paille added a comment.
In D104745#2834796 <https://reviews.llvm.org/D104745#2834796>, @vsk wrote:
> The requirement is that the advancing by sizeof(CovMapFunctionRecordV3) bytes in the record buffer advances to the start of the next record. The address of the buffer doesn't need the same alignment.
The function `advanceByOne(...)` starts with the following assert: ` assert(isAddrAligned(Align(8), this) && "Function record not aligned");` so I tend to think each record needs to be aligned, including the first.
Take the case of the first record created, and assume it has a size multiple of 8. In that case, upon creation no padding is added (independently of it's start address). That's what the snippet below does
while (FuncRecords.size() % 8 != 0)
FuncRecords += '\0';
Now let's assume the start address is not a multiple of 8. In that case next record won't have an address aligned to 8, etc.
A potential patch would be yo compute padding based on the start address instead of the size, but then when the std::string grows, the alignment of the data may change upon reallocation. Thus my patch.
I also tend to think that using a MemoryBuffer conveys more meaning than an `std::string` for what is actually a view on raw data.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104745/new/
https://reviews.llvm.org/D104745
More information about the llvm-commits
mailing list