[ELF] Add profile guided section layout
This adds profile guided layout using the Call-Chain Clustering (C³) heuristic
from https://research.fb.com/wp-content/uploads/2017/01/cgo2017-hfsort-final1.pdf .
RFC: [llvm-dev] [RFC] Profile guided section layout
http://lists.llvm.org/pipermail/llvm-dev/2017-June/114178.html
Pass `--call-graph-ordering-file <file>` to read a call graph profile where each
line has the format:
<from symbol> <to symbol> <call count>
Differential Revision: https://reviews.llvm.org/D36351
llvm-svn: 330234
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index b932c31..1996400 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -248,6 +248,27 @@
message(toString(Sym->File) + S + Sym->getName());
}
+void elf::warnUnorderableSymbol(const Symbol *Sym) {
+ if (!Config->WarnSymbolOrdering)
+ return;
+ const InputFile *File = Sym->File;
+ auto *D = dyn_cast<Defined>(Sym);
+ if (Sym->isUndefined())
+ warn(toString(File) +
+ ": unable to order undefined symbol: " + Sym->getName());
+ else if (Sym->isShared())
+ warn(toString(File) + ": unable to order shared symbol: " + Sym->getName());
+ else if (D && !D->Section)
+ warn(toString(File) +
+ ": unable to order absolute symbol: " + Sym->getName());
+ else if (D && isa<OutputSection>(D->Section))
+ warn(toString(File) +
+ ": unable to order synthetic symbol: " + Sym->getName());
+ else if (D && !D->Section->Repl->Live)
+ warn(toString(File) +
+ ": unable to order discarded symbol: " + Sym->getName());
+}
+
// Returns a symbol for an error message.
std::string lld::toString(const Symbol &B) {
if (Config->Demangle)