Skip to content

Commit bcca1d2

Browse files
committed
Rebase on top of PR#89648
1 parent d1b156c commit bcca1d2

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -813,8 +813,6 @@ void RewriteInstance::discoverFileObjects() {
813813

814814
// For local symbols we want to keep track of associated FILE symbol name for
815815
// disambiguation by combined name.
816-
bool SeenFileName = false;
817-
std::vector<std::pair<DataRefImpl, StringRef>> FileSymbols;
818816
for (const ELFSymbolRef &Symbol : InputFile->symbols()) {
819817
Expected<StringRef> NameOrError = Symbol.getName();
820818
if (NameOrError && NameOrError->starts_with("__asan_init")) {
@@ -833,18 +831,8 @@ void RewriteInstance::discoverFileObjects() {
833831
if (cantFail(Symbol.getFlags()) & SymbolRef::SF_Undefined)
834832
continue;
835833

836-
if (cantFail(Symbol.getType()) == SymbolRef::ST_File) {
834+
if (cantFail(Symbol.getType()) == SymbolRef::ST_File)
837835
FileSymbols.emplace_back(Symbol);
838-
StringRef Name =
839-
cantFail(std::move(NameOrError), "cannot get symbol name for file");
840-
// Ignore Clang LTO artificial FILE symbol as it is not always generated,
841-
// and this uncertainty is causing havoc in function name matching.
842-
if (Name == "ld-temp.o")
843-
continue;
844-
FileSymbols.emplace_back(Symbol.getRawDataRefImpl(), Name);
845-
SeenFileName = true;
846-
continue;
847-
}
848836
}
849837

850838
// Sort symbols in the file by value. Ignore symbols from non-allocatable
@@ -1019,16 +1007,11 @@ void RewriteInstance::discoverFileObjects() {
10191007
// The <id> field is used for disambiguation of local symbols since there
10201008
// could be identical function names coming from identical file names
10211009
// (e.g. from different directories).
1022-
auto CompareSymsByIdx = [](const std::pair<DataRefImpl, StringRef> &A,
1023-
const std::pair<DataRefImpl, StringRef> &B) {
1024-
return A.first.d.b < B.first.d.b;
1025-
};
1026-
DataRefImpl SymDataRef = Symbol.getRawDataRefImpl();
1027-
auto SFI = llvm::upper_bound(FileSymbols,
1028-
std::make_pair(SymDataRef, StringRef()),
1029-
CompareSymsByIdx);
1030-
if (SymbolType == SymbolRef::ST_Function && SFI != FileSymbols.begin())
1031-
AlternativeName = NR.uniquify(Name + "/" + SFI[-1].second.str());
1010+
auto SFI = llvm::upper_bound(FileSymbols, ELFSymbolRef(Symbol));
1011+
if (SymbolType == SymbolRef::ST_Function && SFI != FileSymbols.begin()) {
1012+
StringRef FileSymbolName = cantFail(SFI[-1].getName());
1013+
AlternativeName = NR.uniquify(Name + "/" + FileSymbolName.str());
1014+
}
10321015

10331016
UniqueName = NR.uniquify(Name);
10341017
}

0 commit comments

Comments
 (0)