[PATCH] D110466: [llvm-profgen][CSSPGO] On-demand function size computation for preinliner
Wenlei He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 27 14:01:48 PDT 2021
wenlei added inline comments.
================
Comment at: llvm/tools/llvm-profgen/ProfiledBinary.cpp:550-551
+ uint64_t EndOffset) {
+ uint32_t Index = getIndexForOffset(StartOffset);
+ if (CodeAddrs[Index] != StartOffset)
+ WithColor::warning() << "Invalid start instruction at "
----------------
wlei wrote:
> wenlei wrote:
> > Is this the same as `addressIsCode`? or perhaps we need `addrOffsetIsCode`?
> The input of `addressIsCode` is the `address`. I guess the confusing part is `CodeAddrs` so I changed to `codeAddrOffsets`.
What I meant is we could have something like this:
```
bool addrOffsetIsCode(uint64_t Offset) const {
return Offset2LocStackMap.find(Offset) != Offset2LocStackMap.end();
}
```
which is similar to addressIsCode, except that we use offset now.
```
bool addressIsCode(uint64_t Address) const {
uint64_t Offset = virtualAddrToOffset(Address);
return Offset2LocStackMap.find(Offset) != Offset2LocStackMap.end();
}
```
I think it's cleaner to use API instead of dealing with internals like `codeAddrOffsets` directly when possible. Also `Offset2LocStackMap` is unordered_map while `codeAddrOffsets ` is sorted vector. So look up with `Offset2LocStackMap` is faster.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110466/new/
https://reviews.llvm.org/D110466
More information about the llvm-commits
mailing list