[llvm] r289725 - Only sets profile summary when it was not preset.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 14:06:49 PST 2016


Author: dehao
Date: Wed Dec 14 16:06:49 2016
New Revision: 289725

URL: http://llvm.org/viewvc/llvm-project?rev=289725&view=rev
Log:
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

Modified:
    llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
    llvm/trunk/test/Transforms/SampleProfile/summary.ll

Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=289725&r1=289724&r2=289725&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Wed Dec 14 16:06:49 2016
@@ -1315,7 +1315,8 @@ bool SampleProfileLoader::runOnModule(Mo
       clearFunctionData();
       retval |= runOnFunction(F);
     }
-  M.setProfileSummary(Reader->getSummary().getMD(M.getContext()));
+  if (M.getProfileSummary() == nullptr)
+    M.setProfileSummary(Reader->getSummary().getMD(M.getContext()));
   return retval;
 }
 

Modified: llvm/trunk/test/Transforms/SampleProfile/summary.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/summary.ll?rev=289725&r1=289724&r2=289725&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/summary.ll (original)
+++ llvm/trunk/test/Transforms/SampleProfile/summary.ll Wed Dec 14 16:06:49 2016
@@ -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:




More information about the llvm-commits mailing list