<div dir="ltr">Thanks!</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 10, 2017 at 12:05 PM, Teresa Johnson <span dir="ltr"><<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Should be fixed by r302705.<div>Teresa</div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Wed, May 10, 2017 at 11:09 AM, Easwaran Raman <span dir="ltr"><<a href="mailto:eraman@google.com" target="_blank">eraman@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for letting me know. Teresa is testing a fix and will submit that soon. </div><div class="m_5643416808489985750HOEnZb"><div class="m_5643416808489985750h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 10, 2017 at 10:53 AM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This makes the ubsan bot sad, please fix or revert ASAP.<div><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/4831/steps/check-llvm%20ubsan/logs/stdio" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/sanitizer-x86_64-linux-fas<wbr>t/builds/4831/steps/check-llvm<wbr>%20ubsan/logs/stdio</a><br><div><pre style="font-family:"courier new",courier,monotype,monospace;color:rgb(0,0,0);font-size:medium"><span class="m_5643416808489985750m_7343458520836085270m_5327843212346283215gmail-stdout">lib/Analysis/ModuleSummaryAnal<wbr>ysis.cpp:235:33: runtime error: member call on null pointer of type 'llvm::ProfileSummaryInfo'
    #0 0x216ffea in computeFunctionSummary(llvm::M<wbr>oduleSummaryIndex&, llvm::Module const&, llvm::Function const&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, llvm::DenseSet<unsigned long, llvm::DenseMapInfo<unsigned long> >&) /mnt/b/sanitizer-buildbot3/san<wbr>itizer-x86_64-linux-fast/build<wbr>/llvm/lib/Analysis/ModuleSumma<wbr>ryAnalysis.cpp:235:33
</span></pre></div><div><span class="m_5643416808489985750m_7343458520836085270m_5327843212346283215gmail-stdout"><br></span></div><div><span class="m_5643416808489985750m_7343458520836085270m_5327843212346283215gmail-stdout"><br></span></div></div></div><div class="m_5643416808489985750m_7343458520836085270HOEnZb"><div class="m_5643416808489985750m_7343458520836085270h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 9, 2017 at 4:21 PM, Easwaran Raman via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: eraman<br>
Date: Tue May  9 18:21:10 2017<br>
New Revision: 302597<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302597&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=302597&view=rev</a><br>
Log:<br>
[ProfileSummary] Make getProfileCount a non-static member function.<br>
<br>
This change is required because the notion of count is different for<br>
sample profiling and getProfileCount will need to determine the<br>
underlying profile type.<br>
<br>
Differential revision: <a href="https://reviews.llvm.org/D33012" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3301<wbr>2</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/Analys<wbr>is/ProfileSummaryInfo.h<br>
    llvm/trunk/include/llvm/Transf<wbr>orms/Utils/Cloning.h<br>
    llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp<br>
    llvm/trunk/lib/Transforms/IPO/<wbr>Inliner.cpp<br>
    llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp<br>
    llvm/trunk/lib/Transforms/Util<wbr>s/InlineFunction.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Analys<wbr>is/ProfileSummaryInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ProfileSummaryInfo.h?rev=302597&r1=302596&r2=302597&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/<wbr>Analysis/ProfileSummaryInfo.h?<wbr>rev=302597&r1=302596&r2=302597<wbr>&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/Analys<wbr>is/ProfileSummaryInfo.h (original)<br>
+++ llvm/trunk/include/llvm/Analys<wbr>is/ProfileSummaryInfo.h Tue May  9 18:21:10 2017<br>
@@ -67,8 +67,8 @@ public:<br>
   }<br>
<br>
   /// Returns the profile count for \p CallInst.<br>
-  static Optional<uint64_t> getProfileCount(const Instruction *CallInst,<br>
-                                            BlockFrequencyInfo *BFI);<br>
+  Optional<uint64_t> getProfileCount(const Instruction *CallInst,<br>
+                                     BlockFrequencyInfo *BFI);<br>
   /// \brief Returns true if \p F has hot function entry.<br>
   bool isFunctionEntryHot(const Function *F);<br>
   /// Returns true if \p F has hot function entry or hot call edge.<br>
<br>
Modified: llvm/trunk/include/llvm/Transf<wbr>orms/Utils/Cloning.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Cloning.h?rev=302597&r1=302596&r2=302597&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/<wbr>Transforms/Utils/Cloning.h?rev<wbr>=302597&r1=302596&r2=302597&vi<wbr>ew=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/Transf<wbr>orms/Utils/Cloning.h (original)<br>
+++ llvm/trunk/include/llvm/Transf<wbr>orms/Utils/Cloning.h Tue May  9 18:21:10 2017<br>
@@ -43,6 +43,7 @@ class InvokeInst;<br>
 class Loop;<br>
 class LoopInfo;<br>
 class Module;<br>
+class ProfileSummaryInfo;<br>
 class ReturnInst;<br>
<br>
 /// Return an exact copy of the specified module<br>
@@ -175,15 +176,17 @@ public:<br>
   explicit InlineFunctionInfo(CallGraph *cg = nullptr,<br>
                               std::function<AssumptionCache &(Function &)><br>
                                   *GetAssumptionCache = nullptr,<br>
+                              ProfileSummaryInfo *PSI = nullptr,<br>
                               BlockFrequencyInfo *CallerBFI = nullptr,<br>
                               BlockFrequencyInfo *CalleeBFI = nullptr)<br>
-      : CG(cg), GetAssumptionCache(GetAssumpti<wbr>onCache), CallerBFI(CallerBFI),<br>
-        CalleeBFI(CalleeBFI) {}<br>
+      : CG(cg), GetAssumptionCache(GetAssumpti<wbr>onCache), PSI(PSI),<br>
+        CallerBFI(CallerBFI), CalleeBFI(CalleeBFI) {}<br>
<br>
   /// CG - If non-null, InlineFunction will update the callgraph to reflect the<br>
   /// changes it makes.<br>
   CallGraph *CG;<br>
   std::function<AssumptionCache &(Function &)> *GetAssumptionCache;<br>
+  ProfileSummaryInfo *PSI;<br>
   BlockFrequencyInfo *CallerBFI, *CalleeBFI;<br>
<br>
   /// StaticAllocas - InlineFunction fills this in with all static allocas that<br>
<br>
Modified: llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ModuleSummaryAnalysis.cpp?rev=302597&r1=302596&r2=302597&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Analysis/<wbr>ModuleSummaryAnalysis.cpp?rev=<wbr>302597&r1=302596&r2=302597&vie<wbr>w=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/Module<wbr>SummaryAnalysis.cpp Tue May  9 18:21:10 2017<br>
@@ -232,7 +232,7 @@ computeFunctionSummary(ModuleS<wbr>ummaryInde<br>
         }<br>
         // We should have named any anonymous globals<br>
         assert(CalledFunction->hasNam<wbr>e());<br>
-        auto ScaledCount = ProfileSummaryInfo::getProfile<wbr>Count(&I, BFI);<br>
+        auto ScaledCount = PSI->getProfileCount(&I, BFI);<br>
         auto Hotness = ScaledCount ? getHotness(ScaledCount.getValu<wbr>e(), PSI)<br>
                                    : CalleeInfo::HotnessType::Unkno<wbr>wn;<br>
<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/<wbr>Inliner.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=302597&r1=302596&r2=302597&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/IPO/Inliner.cpp?rev=302597&r<wbr>1=302596&r2=302597&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/IPO/<wbr>Inliner.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/<wbr>Inliner.cpp Tue May  9 18:21:10 2017<br>
@@ -502,7 +502,7 @@ inlineCallsImpl(CallGraphSCC &SCC, CallG<br>
         std::swap(CallSites[i--], CallSites[--FirstCallInSCC]);<br>
<br>
   InlinedArrayAllocasTy InlinedArrayAllocas;<br>
-  InlineFunctionInfo InlineInfo(&CG, &GetAssumptionCache);<br>
+  InlineFunctionInfo InlineInfo(&CG, &GetAssumptionCache, PSI);<br>
<br>
   // Now that we have all of the call sites, loop over them and inline them if<br>
   // it looks profitable to do so.<br>
@@ -872,7 +872,7 @@ PreservedAnalyses InlinerPass::run(LazyC<br>
       // Setup the data structure used to plumb customization into the<br>
       // `InlineFunction` routine.<br>
       InlineFunctionInfo IFI(<br>
-          /*cg=*/nullptr, &GetAssumptionCache,<br>
+          /*cg=*/nullptr, &GetAssumptionCache, PSI,<br>
           &FAM.getResult<BlockFrequency<wbr>Analysis>(*(CS.getCaller())),<br>
           &FAM.getResult<BlockFrequency<wbr>Analysis>(Callee));<br>
<br>
<br>
Modified: llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp?rev=302597&r1=302596&r2=302597&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/IPO/PartialInlining.cpp?rev=<wbr>302597&r1=302596&r2=302597&vie<wbr>w=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp Tue May  9 18:21:10 2017<br>
@@ -473,7 +473,7 @@ Function *PartialInlinerImpl::unswitchF<wbr>u<br>
              << ore::NV("Callee", F) << " partially inlined into "<br>
              << ore::NV("Caller", CS.getCaller()));<br>
<br>
-    InlineFunctionInfo IFI(nullptr, GetAssumptionCache);<br>
+    InlineFunctionInfo IFI(nullptr, GetAssumptionCache, PSI);<br>
     InlineFunction(CS, IFI);<br>
     NumPartialInlining++;<br>
     // update stats<br>
<br>
Modified: llvm/trunk/lib/Transforms/Util<wbr>s/InlineFunction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=302597&r1=302596&r2=302597&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/Utils/InlineFunction.cpp?rev<wbr>=302597&r1=302596&r2=302597&vi<wbr>ew=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/Util<wbr>s/InlineFunction.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Util<wbr>s/InlineFunction.cpp Tue May  9 18:21:10 2017<br>
@@ -1396,11 +1396,12 @@ static void updateCallerBFI(BasicBlock *<br>
 /// Update the branch metadata for cloned call instructions.<br>
 static void updateCallProfile(Function *Callee, const ValueToValueMapTy &VMap,<br>
                               const Optional<uint64_t> &CalleeEntryCount,<br>
-                              const Instruction *TheCall) {<br>
+                              const Instruction *TheCall,<br>
+                              ProfileSummaryInfo *PSI) {<br>
   if (!CalleeEntryCount.hasValue() || CalleeEntryCount.getValue() < 1)<br>
     return;<br>
   Optional<uint64_t> CallSiteCount =<br>
-      ProfileSummaryInfo::getProfile<wbr>Count(TheCall, nullptr);<br>
+      PSI ? PSI->getProfileCount(TheCall, nullptr) : None;<br>
   uint64_t CallCount =<br>
       std::min(CallSiteCount.hasVal<wbr>ue() ? CallSiteCount.getValue() : 0,<br>
                CalleeEntryCount.getValue());<br>
@@ -1423,16 +1424,16 @@ static void updateCallProfile(Function *<br>
 /// The callsite's block count is subtracted from the callee's function entry<br>
 /// count.<br>
 static void updateCalleeCount(BlockFrequen<wbr>cyInfo *CallerBFI, BasicBlock *CallBB,<br>
-                              Instruction *CallInst, Function *Callee) {<br>
+                              Instruction *CallInst, Function *Callee,<br>
+                              ProfileSummaryInfo *PSI) {<br>
   // If the callee has a original count of N, and the estimated count of<br>
   // callsite is M, the new callee count is set to N - M. M is estimated from<br>
   // the caller's entry count, its entry block frequency and the block frequency<br>
   // of the callsite.<br>
   Optional<uint64_t> CalleeCount = Callee->getEntryCount();<br>
-  if (!CalleeCount.hasValue())<br>
+  if (!CalleeCount.hasValue() || !PSI)<br>
     return;<br>
-  Optional<uint64_t> CallCount =<br>
-      ProfileSummaryInfo::getProfile<wbr>Count(CallInst, CallerBFI);<br>
+  Optional<uint64_t> CallCount = PSI->getProfileCount(CallInst, CallerBFI);<br>
   if (!CallCount.hasValue())<br>
     return;<br>
   // Since CallSiteCount is an estimate, it could exceed the original callee<br>
@@ -1635,9 +1636,10 @@ bool llvm::InlineFunction(CallSite CS, I<br>
       updateCallerBFI(OrigBB, VMap, IFI.CallerBFI, IFI.CalleeBFI,<br>
                       CalledFunc->front());<br>
<br>
-    updateCallProfile(CalledFunc, VMap, CalledFunc->getEntryCount(), TheCall);<br>
+    updateCallProfile(CalledFunc, VMap, CalledFunc->getEntryCount(), TheCall,<br>
+                      IFI.PSI);<br>
     // Update the profile count of callee.<br>
-    updateCalleeCount(IFI.CallerBF<wbr>I, OrigBB, TheCall, CalledFunc);<br>
+    updateCalleeCount(IFI.CallerBF<wbr>I, OrigBB, TheCall, CalledFunc, IFI.PSI);<br>
<br>
     // Inject byval arguments initialization.<br>
     for (std::pair<Value*, Value*> &Init : ByValInit)<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_5643416808489985750gmail_signature" data-smartmail="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> <a href="tel:(408)%20460-2413" value="+14084602413" target="_blank">408-460-2413</a></td></tr></tbody></table></span></div>
</font></span></div>
</blockquote></div><br></div>