diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-02-01 20:16:35 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-02-01 20:16:35 +0000 |
commit | 2d9da4dc501d71a4be5f56c40ed47a9f3ce8430e (patch) | |
tree | 8841dd7d4f91ef5c4548091086a928f204cbf132 | |
parent | 5c94f2942e33a5a294a577789b706785d921fab4 (diff) | |
download | bcm5719-llvm-2d9da4dc501d71a4be5f56c40ed47a9f3ce8430e.tar.gz bcm5719-llvm-2d9da4dc501d71a4be5f56c40ed47a9f3ce8430e.zip |
[ThinLTO] Ensure function summary output order is stable
Iterate over the function list instead of a DenseMap of Function pointers
when emitting the function summary into the module.
This fixes PR26419.
llvm-svn: 259398
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 3f1d2683532..5f85882cd40 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -2800,16 +2800,22 @@ static void WritePerModuleFunctionSummary( unsigned FSAbbrev = Stream.EmitAbbrev(Abbv); SmallVector<unsigned, 64> NameVals; - for (auto &I : FunctionIndex) { + // Iterate over the list of functions instead of the FunctionIndex map to + // ensure the ordering is stable. + for (const Function &F : *M) { + if (F.isDeclaration()) + continue; // Skip anonymous functions. We will emit a function summary for // any aliases below. - if (!I.first->hasName()) + if (!F.hasName()) continue; + assert(FunctionIndex.count(&F) == 1); + WritePerModuleFunctionSummaryRecord( - NameVals, I.second->functionSummary(), - VE.getValueID(M->getValueSymbolTable().lookup(I.first->getName())), - FSAbbrev, Stream); + NameVals, FunctionIndex[&F]->functionSummary(), + VE.getValueID(M->getValueSymbolTable().lookup(F.getName())), FSAbbrev, + Stream); } for (const GlobalAlias &A : M->aliases()) { |