[PATCH] D110795: [llvm-profgen] Fix alignment in preferred based calculation
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 29 23:05:21 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47d66355ef90: [llvm-profgen] Fix alignment in preferred based calculation (authored by wenlei).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110795/new/
https://reviews.llvm.org/D110795
Files:
llvm/tools/llvm-profgen/ProfiledBinary.cpp
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -233,11 +233,17 @@
template <class ELFT>
void ProfiledBinary::setPreferredTextSegmentAddresses(const ELFFile<ELFT> &Obj, StringRef FileName) {
const auto &PhdrRange = unwrapOrError(Obj.program_headers(), FileName);
+ // FIXME: This should be the page size of the system running profiling.
+ // However such info isn't available at post-processing time, assuming
+ // 4K page now. Note that we don't use EXEC_PAGESIZE from <linux/param.h>
+ // because we may build the tools on non-linux.
+ uint32_t PageSize = 0x1000;
for (const typename ELFT::Phdr &Phdr : PhdrRange) {
if ((Phdr.p_type == ELF::PT_LOAD) && (Phdr.p_flags & ELF::PF_X)) {
// Segments will always be loaded at a page boundary.
- PreferredTextSegmentAddresses.push_back(Phdr.p_vaddr & ~(Phdr.p_align - 1U));
- TextSegmentOffsets.push_back(Phdr.p_offset & ~(Phdr.p_align - 1U));
+ PreferredTextSegmentAddresses.push_back(Phdr.p_vaddr &
+ ~(PageSize - 1U));
+ TextSegmentOffsets.push_back(Phdr.p_offset & ~(PageSize - 1U));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110795.376112.patch
Type: text/x-patch
Size: 1318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210930/7133e790/attachment.bin>
More information about the llvm-commits
mailing list