<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">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/4831/steps/check-llvm%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="gmail-stdout">lib/Analysis/ModuleSummaryAnalysis.cpp:235:33: runtime error: member call on null pointer of type 'llvm::ProfileSummaryInfo'
    #0 0x216ffea in computeFunctionSummary(llvm::ModuleSummaryIndex&, llvm::Module const&, llvm::Function const&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, bool, llvm::DenseSet<unsigned long, llvm::DenseMapInfo<unsigned long> >&) /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp:235:33
</span></pre></div><div><span class="gmail-stdout"><br></span></div><div><span class="gmail-stdout"><br></span></div></div></div><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-<wbr>project?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/<wbr>D33012</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/<wbr>Analysis/ProfileSummaryInfo.h<br>
    llvm/trunk/include/llvm/<wbr>Transforms/Utils/Cloning.h<br>
    llvm/trunk/lib/Analysis/<wbr>ModuleSummaryAnalysis.cpp<br>
    llvm/trunk/lib/Transforms/IPO/<wbr>Inliner.cpp<br>
    llvm/trunk/lib/Transforms/IPO/<wbr>PartialInlining.cpp<br>
    llvm/trunk/lib/Transforms/<wbr>Utils/InlineFunction.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>Analysis/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-<wbr>project/llvm/trunk/include/<wbr>llvm/Analysis/<wbr>ProfileSummaryInfo.h?rev=<wbr>302597&r1=302596&r2=302597&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>Analysis/ProfileSummaryInfo.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>Analysis/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/<wbr>Transforms/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-<wbr>project/llvm/trunk/include/<wbr>llvm/Transforms/Utils/Cloning.<wbr>h?rev=302597&r1=302596&r2=<wbr>302597&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>Transforms/Utils/Cloning.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>Transforms/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(<wbr>GetAssumptionCache), CallerBFI(CallerBFI),<br>
-        CalleeBFI(CalleeBFI) {}<br>
+      : CG(cg), GetAssumptionCache(<wbr>GetAssumptionCache), 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/<wbr>ModuleSummaryAnalysis.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-<wbr>project/llvm/trunk/lib/<wbr>Analysis/<wbr>ModuleSummaryAnalysis.cpp?rev=<wbr>302597&r1=302596&r2=302597&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Analysis/<wbr>ModuleSummaryAnalysis.cpp (original)<br>
+++ llvm/trunk/lib/Analysis/<wbr>ModuleSummaryAnalysis.cpp Tue May  9 18:21:10 2017<br>
@@ -232,7 +232,7 @@ computeFunctionSummary(<wbr>ModuleSummaryInde<br>
         }<br>
         // We should have named any anonymous globals<br>
         assert(CalledFunction-><wbr>hasName());<br>
-        auto ScaledCount = ProfileSummaryInfo::<wbr>getProfileCount(&I, BFI);<br>
+        auto ScaledCount = PSI->getProfileCount(&I, BFI);<br>
         auto Hotness = ScaledCount ? getHotness(ScaledCount.<wbr>getValue(), PSI)<br>
                                    : CalleeInfo::HotnessType::<wbr>Unknown;<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-<wbr>project/llvm/trunk/lib/<wbr>Transforms/IPO/Inliner.cpp?<wbr>rev=302597&r1=302596&r2=<wbr>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<<wbr>BlockFrequencyAnalysis>(*(CS.<wbr>getCaller())),<br>
           &FAM.getResult<<wbr>BlockFrequencyAnalysis>(<wbr>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-<wbr>project/llvm/trunk/lib/<wbr>Transforms/IPO/<wbr>PartialInlining.cpp?rev=<wbr>302597&r1=302596&r2=302597&<wbr>view=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::<wbr>unswitchFu<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/<wbr>Utils/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-<wbr>project/llvm/trunk/lib/<wbr>Transforms/Utils/<wbr>InlineFunction.cpp?rev=302597&<wbr>r1=302596&r2=302597&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>Utils/InlineFunction.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>Utils/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::<wbr>getProfileCount(TheCall, nullptr);<br>
+      PSI ? PSI->getProfileCount(TheCall, nullptr) : None;<br>
   uint64_t CallCount =<br>
       std::min(CallSiteCount.<wbr>hasValue() ? 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(<wbr>BlockFrequencyInfo *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::<wbr>getProfileCount(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.<wbr>CallerBFI, OrigBB, TheCall, CalledFunc);<br>
+    updateCalleeCount(IFI.<wbr>CallerBFI, 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">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>