Only sets profile summary when it was not preset.

Summary: SampleProfileLoader pass may be invoked twice by LTO. The 2nd pass should not append more summary info as it is already preset by the 1st pass.

Reviewers: eraman, davidxl

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D27733

llvm-svn: 289725
This commit is contained in:
Dehao Chen 2016-12-14 22:06:49 +00:00
parent fb699619a0
commit 40dd8c5109
2 changed files with 3 additions and 1 deletions

View File

@ -1315,7 +1315,8 @@ bool SampleProfileLoader::runOnModule(Module &M) {
clearFunctionData();
retval |= runOnFunction(F);
}
M.setProfileSummary(Reader->getSummary().getMD(M.getContext()));
if (M.getProfileSummary() == nullptr)
M.setProfileSummary(Reader->getSummary().getMD(M.getContext()));
return retval;
}

View File

@ -1,5 +1,6 @@
; Test that we annotate entire program's summary to IR.
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/summary.prof -S | FileCheck %s
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/summary.prof -S | opt -sample-profile -sample-profile-file=%S/Inputs/summary.prof -S | FileCheck %s
define i32 @bar() #0 !dbg !1 {
entry: