Skip to content

Commit 5eead6b

Browse files
committed
Clean up getSymbolSize API and warnings
1 parent e12e694 commit 5eead6b

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

llvm/include/llvm/Object/ELFObjectFile.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
310310
uint64_t getSymbolValueImpl(DataRefImpl Symb) const override;
311311
uint32_t getSymbolAlignment(DataRefImpl Symb) const override;
312312
uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const override;
313+
uint64_t getSymbolSizeImpl(DataRefImpl Symb) const override;
313314
Expected<uint32_t> getSymbolFlags(DataRefImpl Symb) const override;
314315
uint8_t getSymbolBinding(DataRefImpl Symb) const override;
315316
uint8_t getSymbolOther(DataRefImpl Symb) const override;
@@ -703,6 +704,11 @@ uint64_t ELFObjectFile<ELFT>::getCommonSymbolSizeImpl(DataRefImpl Symb) const {
703704
return getSymbolSize(Symb);
704705
}
705706

707+
template <class ELFT>
708+
uint64_t ELFObjectFile<ELFT>::getSymbolSizeImpl(DataRefImpl Symb) const {
709+
return getSymbolSize(Symb);
710+
}
711+
706712
template <class ELFT>
707713
uint8_t ELFObjectFile<ELFT>::getSymbolBinding(DataRefImpl Symb) const {
708714
Expected<const Elf_Sym *> SymOrErr = getSymbol(Symb);

llvm/include/llvm/Object/ObjectFile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class LLVM_ABI ObjectFile : public SymbolicFile {
256256
virtual uint64_t getSymbolValueImpl(DataRefImpl Symb) const = 0;
257257
virtual uint32_t getSymbolAlignment(DataRefImpl Symb) const;
258258
virtual uint64_t getCommonSymbolSizeImpl(DataRefImpl Symb) const = 0;
259+
virtual uint64_t getSymbolSizeImpl(DataRefImpl Symb) const { return 0; }
259260
virtual Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const = 0;
260261
virtual Expected<section_iterator>
261262
getSymbolSection(DataRefImpl Symb) const = 0;
@@ -484,7 +485,7 @@ inline uint64_t SymbolRef::getCommonSize() const {
484485
}
485486

486487
inline uint64_t SymbolRef::getSize() const {
487-
return getObject()->getCommonSymbolSizeImpl(getRawDataRefImpl());
488+
return getObject()->getSymbolSizeImpl(getRawDataRefImpl());
488489
}
489490

490491
inline Expected<section_iterator> SymbolRef::getSection() const {

llvm/tools/llvm-profgen/PerfReader.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,16 +1274,13 @@ void PerfScriptReader::warnInvalidRange() {
12741274

12751275
const char *EndNotBoundaryMsg = "Range is not on instruction boundary, "
12761276
"likely due to profile and binary mismatch.";
1277-
const char *DanglingRangeMsg = "Range does not belong to any functions, "
1278-
"likely from PLT, .init or .fini section.";
12791277
const char *RangeCrossFuncMsg =
12801278
"Fall through range should not cross function boundaries, likely due to "
12811279
"profile and binary mismatch.";
12821280
const char *BogusRangeMsg = "Range start is after or too far from range end.";
12831281

12841282
uint64_t TotalRangeNum = 0;
12851283
uint64_t InstNotBoundary = 0;
1286-
uint64_t UnmatchedRange = 0;
12871284
uint64_t RangeCrossFunc = 0;
12881285
uint64_t BogusRange = 0;
12891286

@@ -1303,11 +1300,8 @@ void PerfScriptReader::warnInvalidRange() {
13031300
}
13041301

13051302
auto *FRange = Binary->findFuncRange(StartAddress);
1306-
if (!FRange) {
1307-
UnmatchedRange += I.second;
1308-
WarnInvalidRange(StartAddress, EndAddress, DanglingRangeMsg);
1303+
if (!FRange)
13091304
continue;
1310-
}
13111305

13121306
if (EndAddress >= FRange->EndAddress) {
13131307
RangeCrossFunc += I.second;
@@ -1325,9 +1319,6 @@ void PerfScriptReader::warnInvalidRange() {
13251319
emitWarningSummary(
13261320
InstNotBoundary, TotalRangeNum,
13271321
"of samples are from ranges that are not on instruction boundary.");
1328-
emitWarningSummary(
1329-
UnmatchedRange, TotalRangeNum,
1330-
"of samples are from ranges that do not belong to any functions.");
13311322
emitWarningSummary(
13321323
RangeCrossFunc, TotalRangeNum,
13331324
"of samples are from ranges that do cross function boundaries.");

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@ void ProfiledBinary::populateSymbolAddressList(const ObjectFile *Obj) {
824824

825825
void ProfiledBinary::populateSymbolsFromBinary(const ObjectFile *Obj) {
826826
// Load binary functions from symbol table when Debug info is incomplete
827+
const char *Suffixes[] = {".destroy", ".resume", ".llvm.",
828+
".cold", ".warm", nullptr};
827829
StringRef FileName = Obj->getFileName();
828830
for (const SymbolRef &Symbol : Obj->symbols()) {
829831
const SymbolRef::Type Type = unwrapOrError(Symbol.getType(), FileName);
@@ -834,8 +836,6 @@ void ProfiledBinary::populateSymbolsFromBinary(const ObjectFile *Obj) {
834836
if (Size == 0 || Type != SymbolRef::ST_Function)
835837
continue;
836838

837-
const char *Suffixes[] = {".destroy", ".resume", ".llvm.",
838-
".cold", ".warm", nullptr};
839839
const StringRef SymName =
840840
FunctionSamples::getCanonicalFnName(Name, Suffixes);
841841

0 commit comments

Comments
 (0)