<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thanks Evgenii. Sorry I wasn’t responsive, I’ve been on holiday without any laptop. I’ll look into the issues and try to update the patch.<div class=""><br class=""></div><div class="">Tim.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 13 Jul 2018, at 17:37, Evgenii Stepanov <<a href="mailto:eugeni.stepanov@gmail.com" class="">eugeni.stepanov@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Reverted in r337018.<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Jul 13, 2018 at 9:34 AM, Evgenii Stepanov <span dir="ltr" class=""><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank" class="">eugeni.stepanov@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Thank you. So an SCC pass (Inliner in this case) may invalidate the CallGraph iterator held in the loop in CGPassManager::runOnModule by removing a function from the module. This is clearly a bug in this change, reverting.<div class=""><br class=""><div class=""><br class=""></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Jul 13, 2018 at 9:00 AM, Sumanth Gundapaneni <span dir="ltr" class=""><<a href="mailto:sgundapa@codeaurora.org" target="_blank" class="">sgundapa@codeaurora.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple" class=""><div class=""><p class="MsoNormal">I was able to reproduce the problem consistently with my ASAN build. <u class=""></u><u class=""></u></p><p class="MsoNormal">I cannot share the source code but I can share the crash log.<u class=""></u><u class=""></u></p><p class="MsoNormal">It is a “heap-use-after-free” that comes from debug statement (#ifndef NDEBUG).<u class=""></u><u class=""></u></p><p class="MsoNormal">Hopefully this helps.<u class=""></u><u class=""></u></p><p class="MsoNormal"><u class=""></u> <u class=""></u></p><p class="MsoNormal">--Sumanth<u class=""></u><u class=""></u></p><p class="MsoNormal"><b class="">From:</b> llvm-commits [mailto:<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank" class="">llvm-commits-bounces@l<wbr class="">ists.llvm.org</a>] <b class="">On Behalf Of </b>Evgenii Stepanov via llvm-commits<br class=""><b class="">Sent:</b> Friday, July 13, 2018 10:24 AM<br class=""><b class="">To:</b> Galina Kistanova <<a href="mailto:gkistanova@gmail.com" target="_blank" class="">gkistanova@gmail.com</a>><br class=""><b class="">Cc:</b> LLVM Commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>><br class=""><b class="">Subject:</b> Re: [llvm] r336419 - CallGraphSCCPass: iterate over all functions.<u class=""></u><u class=""></u></p><div class=""><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p><div class=""><p class="MsoNormal">MSan buildbot crashes are still happening, once per 8 builds or so. I can't reproduce them locally and am not 100% sure that this is the change, but, given the nondeterminism detected on the other bot, I'm going to tentatively revert it.<u class=""></u><u class=""></u></p><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p><div class=""><p class="MsoNormal">On Thu, Jul 12, 2018 at 12:01 PM, Galina Kistanova <<a href="mailto:gkistanova@gmail.com" target="_blank" class="">gkistanova@gmail.com</a>> wrote:<u class=""></u><u class=""></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in" class=""><div class=""><div class=""><p class="MsoNormal">Hello Tim,<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">This commit has introduced nondeterminism. Please see <a href="http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu" target="_blank" class="">http://lab.llvm.org:8011/build<wbr class="">ers/clang-with-thin-lto-ubuntu</a> or <a href="http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu" target="_blank" class="">http://lab.llvm.org:8011/build<wbr class="">ers/clang-with-lto-ubuntu</a> build bots.<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">This is in addition to those other problems mentioned already, or maybe some of the other problems are exposed because of this.<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">Since the problem is around for quite long now, maybe it worth reverting till you will figure out what's wrong and how to fix it?<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">Thanks<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><span style="color:#888888" class=""><u class=""></u> <u class=""></u></span></p></div><div class=""><p class="MsoNormal"><span style="color:#888888" class="">Galina<u class=""></u><u class=""></u></span></p></div><div class=""><p class="MsoNormal"><span style="color:#888888" class=""><u class=""></u> <u class=""></u></span></p></div><div class=""><p class="MsoNormal"><span style="color:#888888" class=""><u class=""></u> <u class=""></u></span></p></div><div class=""><p class="MsoNormal"><span style="color:#888888" class=""><u class=""></u> <u class=""></u></span></p></div></div><div class=""><div class=""><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p><div class=""><p class="MsoNormal">On Tue, Jul 10, 2018 at 1:33 PM, Evgenii Stepanov via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>> wrote:<u class=""></u><u class=""></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in" class=""><div class=""><div class=""><p class="MsoNormal">Hi Tim,<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">MSan bootstrap bot has been randomly crashing lately with the following trace:<u class=""></u><u class=""></u></p></div><div class=""><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">3. Running pass 'CallGraph Pass Manager' on module '/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm/lib/Tar<wbr class="">get/Hexagon/HexagonCommonGEP.<wbr class="">cpp'.<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#0 0x00005602f79f5cfa llvm::sys::PrintStackTrace(llv<wbr class="">m::raw_ostream&) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x24f5cfa)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#1 0x00005602f79f42c5 llvm::sys::RunSignalHandlers() (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x24f42c5)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#2 0x00005602f79f43dc SignalHandler(int) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x24f43dc)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#3 0x00007f63daa840c0 __restore_rt (/lib/x86_64-linux-gnu/libpthr<wbr class="">ead.so.0+0x110c0)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#4 0x00005602f6edf38e llvm::scc_iterator<llvm::CallG<wbr class="">raph*, llvm::GraphTraits<llvm::CallGr<wbr class="">aph*> >::DFSVisitChildren() (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x19df38e)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#5 0x00005602f6edf5aa llvm::scc_iterator<llvm::CallG<wbr class="">raph*, llvm::GraphTraits<llvm::CallGr<wbr class="">aph*> >::GetNextSCC() (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x19df5aa)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#6 0x00005602f6ee05ed (anonymous namespace)::CGPassManager::run<wbr class="">OnModule(llvm::Module&) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x19e05ed)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#7 0x00005602f74ca5fd llvm::legacy::PassManagerImpl:<wbr class="">:run(llvm::Module&) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x1fca5fd)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#8 0x00005602f7bde5c1 (anonymous namespace)::EmitAssemblyHelper<wbr class="">::EmitAssembly(clang::BackendA<wbr class="">ction, std::unique_ptr<llvm::raw_pwri<wbr class="">te_stream, std::default_delete<llvm::raw_<wbr class="">pwrite_stream> >) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x26de5c1)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#9 0x00005602f7bdfdf0 clang::EmitBackendOutput(clang<wbr class="">::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwri<wbr class="">te_stream, std::default_delete<llvm::raw_<wbr class="">pwrite_stream> >) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x26dfdf0)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#10 0x00005602f836f264 clang::BackendConsumer::Handle<wbr class="">TranslationUnit(clang::ASTCont<wbr class="">ext&) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x2e6f264)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#11 0x00005602f8b37fa9 clang::ParseAST(clang::Sema&, bool, bool) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x3637fa9)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#12 0x00005602f836e4d9 clang::CodeGenAction::ExecuteA<wbr class="">ction() (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x2e6e4d9)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#13 0x00005602f800da7e clang::FrontendAction::Execute<wbr class="">() (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x2b0da7e)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#14 0x00005602f7fd9496 clang::CompilerInstance::Execu<wbr class="">teAction(clang::FrontendAction<wbr class="">&) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x2ad9496)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#15 0x00005602f80ad511 clang::ExecuteCompilerInvocati<wbr class="">on(clang::CompilerInstance*) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0x2bad511)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#16 0x00005602f614c080 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0xc4c080)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#17 0x00005602f60c1a22 main (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0xbc1a22)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#18 0x00007f63d98312e1 __libc_start_main (/lib/x86_64-linux-gnu/libc.so<wbr class="">.6+0x202e1)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">#19 0x00005602f61480aa _start (/b/sanitizer-x86_64-linux-boo<wbr class="">tstrap-msan/build/llvm_build0/<wbr class="">bin/clang-7+0xc480aa)<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal">clang-7: error: unable to execute command: Segmentation fault<u class=""></u><u class=""></u></p></div></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">The crash happens roughly in 1 out of 5-to-10 builds, see history here:<u class=""></u><u class=""></u></p></div><p class="MsoNormal"><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan?numbuilds=300" target="_blank" class="">http://lab.llvm.org:8011/build<wbr class="">ers/sanitizer-x86_64-linux-<wbr class="">bootstrap-msan?numbuilds=300</a><u class=""></u><u class=""></u></p><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">The earliest it happened was this build at r336432:<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-msan/builds/5763" target="_blank" class="">http://lab.llvm.org:8011/build<wbr class="">ers/sanitizer-x86_64-linux-<wbr class="">bootstrap-msan/builds/5763</a><u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div><div class=""><p class="MsoNormal">I suspect that this change could be the culprit. Could you take a look?<u class=""></u><u class=""></u></p></div><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div></div><div class=""><div class=""><div class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p><div class=""><p class="MsoNormal">On Fri, Jul 6, 2018 at 1:04 AM, Tim Northover via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>> wrote:<u class=""></u><u class=""></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in" class=""><p class="MsoNormal">Author: tnorthover<br class="">Date: Fri Jul  6 01:04:47 2018<br class="">New Revision: 336419<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=336419&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject?rev=336419&view=rev</a><br class="">Log:<br class="">CallGraphSCCPass: iterate over all functions.<br class=""><br class="">Previously we only iterated over functions reachable from the set of<br class="">external functions in the module. But since some of the passes under<br class="">this (notably the always-inliner and coroutine lowerer) are required for<br class="">correctness, they need to run over everything.<br class=""><br class="">This just adds an extra layer of iteration over the CallGraph to keep<br class="">track of which functions we've already visited and get the next batch of<br class="">SCCs.<br class=""><br class="">Should fix PR38029.<br class=""><br class="">Modified:<br class="">    llvm/trunk/include/llvm/ADT/SC<wbr class="">CIterator.h<br class="">    llvm/trunk/lib/Analysis/CallGr<wbr class="">aphSCCPass.cpp<br class="">    llvm/trunk/test/Transforms/Inl<wbr class="">ine/always-inline.ll<br class=""><br class="">Modified: llvm/trunk/include/llvm/ADT/SC<wbr class="">CIterator.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SCCIterator.h?rev=336419&r1=336418&r2=336419&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/llvm/trunk/include/llvm/<wbr class="">ADT/SCCIterator.h?rev=336419&<wbr class="">r1=336418&r2=336419&view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- llvm/trunk/include/llvm/ADT/SC<wbr class="">CIterator.h (original)<br class="">+++ llvm/trunk/include/llvm/ADT/SC<wbr class="">CIterator.h Fri Jul  6 01:04:47 2018<br class="">@@ -90,6 +90,7 @@ class scc_iterator : public iterator_fac<br class="">   /// Compute the next SCC using the DFS traversal.<br class="">   void GetNextSCC();<br class=""><br class="">+public:<br class="">   scc_iterator(NodeRef entryN) : visitNum(0) {<br class="">     DFSVisitOne(entryN);<br class="">     GetNextSCC();<br class="">@@ -98,12 +99,6 @@ class scc_iterator : public iterator_fac<br class="">   /// End is when the DFS stack is empty.<br class="">   scc_iterator() = default;<br class=""><br class="">-public:<br class="">-  static scc_iterator begin(const GraphT &G) {<br class="">-    return scc_iterator(GT::getEntryNode(<wbr class="">G));<br class="">-  }<br class="">-  static scc_iterator end(const GraphT &) { return scc_iterator(); }<br class="">-<br class="">   /// Direct loop termination test which is more efficient than<br class="">   /// comparison with \c end().<br class="">   bool isAtEnd() const {<br class="">@@ -222,16 +217,25 @@ bool scc_iterator<GraphT, GT>::hasLoop()<br class="">     return false;<br class="">   }<br class=""><br class="">-/// Construct the begin iterator for a deduced graph type T.<br class="">+/// Construct the begin iterator for a deduced graph type T, starting from its<br class="">+/// entry node.<br class=""> template <class T> scc_iterator<T> scc_begin(const T &G) {<br class="">-  return scc_iterator<T>::begin(G);<br class="">+  return scc_iterator<T>(GraphTraits<T><wbr class="">::getEntryNode(G));<br class=""> }<br class=""><br class="">-/// Construct the end iterator for a deduced graph type T.<br class="">+/// Construct the begin iterator for a graph type T, starting from the specified<br class="">+/// node.<br class="">+template <class T, class U = GraphTraits<T>><br class="">+scc_iterator<T, U> scc_begin(typename U::NodeRef N) {<br class="">+  return scc_iterator<T>(N);<br class="">+}<br class="">+<br class="">+  /// Construct the end iterator for a deduced graph type T.<br class=""> template <class T> scc_iterator<T> scc_end(const T &G) {<br class="">-  return scc_iterator<T>::end(G);<br class="">+  return scc_iterator<T>();<br class=""> }<br class=""><br class="">+<br class=""> } // end namespace llvm<br class=""><br class=""> #endif // LLVM_ADT_SCCITERATOR_H<br class=""><br class="">Modified: llvm/trunk/lib/Analysis/CallGr<wbr class="">aphSCCPass.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CallGraphSCCPass.cpp?rev=336419&r1=336418&r2=336419&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/llvm/trunk/lib/Analysis/<wbr class="">CallGraphSCCPass.cpp?rev=<wbr class="">336419&r1=336418&r2=336419&<wbr class="">view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- llvm/trunk/lib/Analysis/CallGr<wbr class="">aphSCCPass.cpp (original)<br class="">+++ llvm/trunk/lib/Analysis/CallGr<wbr class="">aphSCCPass.cpp Fri Jul  6 01:04:47 2018<br class="">@@ -17,6 +17,7 @@<br class=""><br class=""> #include "llvm/Analysis/CallGraphSCCPas<wbr class="">s.h"<br class=""> #include "llvm/ADT/DenseMap.h"<br class="">+#include "llvm/ADT/DenseSet.h"<br class=""> #include "llvm/ADT/SCCIterator.h"<br class=""> #include "llvm/ADT/Statistic.h"<br class=""> #include "llvm/Analysis/CallGraph.h"<br class="">@@ -63,6 +64,10 @@ public:<br class="">   /// whether any of the passes modifies the module, and if so, return true.<br class="">   bool runOnModule(Module &M) override;<br class=""><br class="">+  /// Execute all of the passes scheduled for execution on a given SCC. Return<br class="">+  /// true if any passes modify the module.<br class="">+  bool runOnSCC(CallGraphSCC &SCC, CallGraph &CG);<br class="">+<br class="">   using ModulePass::doInitialization;<br class="">   using ModulePass::doFinalization;<br class=""><br class="">@@ -448,51 +453,78 @@ bool CGPassManager::RunAllPassesOnS<wbr class="">CC(Ca<br class=""> bool CGPassManager::runOnModule(Mod<wbr class="">ule &M) {<br class="">   CallGraph &CG = getAnalysis<CallGraphWrapperPa<wbr class="">ss>().getCallGraph();<br class="">   bool Changed = doInitialization(CG);<br class="">-  <br class="">-  // Walk the callgraph in bottom-up SCC order.<br class="">-  scc_iterator<CallGraph*> CGI = scc_begin(&CG);<br class=""><br class="">-  CallGraphSCC CurSCC(CG, &CGI);<br class="">-  while (!CGI.isAtEnd()) {<br class="">-    // Copy the current SCC and increment past it so that the pass can hack<br class="">-    // on the SCC if it wants to without invalidating our iterator.<br class="">-    const std::vector<CallGraphNode *> &NodeVec = *CGI;<br class="">-    CurSCC.initialize(NodeVec);<br class="">-    ++CGI;<br class="">-<br class="">-    // At the top level, we run all the passes in this pass manager on the<br class="">-    // functions in this SCC.  However, we support iterative compilation in the<br class="">-    // case where a function pass devirtualizes a call to a function.  For<br class="">-    // example, it is very common for a function pass (often GVN or instcombine)<br class="">-    // to eliminate the addressing that feeds into a call.  With that improved<br class="">-    // information, we would like the call to be an inline candidate, infer<br class="">-    // mod-ref information etc.<br class="">-    //<br class="">-    // Because of this, we allow iteration up to a specified iteration count.<br class="">-    // This only happens in the case of a devirtualized call, so we only burn<br class="">-    // compile time in the case that we're making progress.  We also have a hard<br class="">-    // iteration count limit in case there is crazy code.<br class="">-    unsigned Iteration = 0;<br class="">-    bool DevirtualizedCall = false;<br class="">-    do {<br class="">-      LLVM_DEBUG(if (Iteration) dbgs()<br class="">-                 << "  SCCPASSMGR: Re-visiting SCC, iteration #" << Iteration<br class="">-                 << '\n');<br class="">-      DevirtualizedCall = false;<br class="">-      Changed |= RunAllPassesOnSCC(CurSCC, CG, DevirtualizedCall);<br class="">-    } while (Iteration++ < MaxIterations && DevirtualizedCall);<br class="">-    <br class="">-    if (DevirtualizedCall)<br class="">-      LLVM_DEBUG(dbgs() << "  CGSCCPASSMGR: Stopped iteration after "<br class="">-                        << Iteration<br class="">-                        << " times, due to -max-cg-scc-iterations\n");<br class="">+  DenseSet<const Function *> Visited;<br class=""><br class="">-    MaxSCCIterations.updateMax(Ite<wbr class="">ration);<br class="">+  CallGraph::iterator INext;<br class="">+  for (auto I = CG.begin(), E = CG.end(); I != E;) {<br class="">+    // Walk the callgraph in bottom-up SCC order.<br class="">+    auto CGI = scc_begin<CallGraph *>(I->second.get());<br class="">+<br class="">+    CallGraphSCC CurSCC(CG, &CGI);<br class="">+    while (!CGI.isAtEnd()) {<br class="">+      const std::vector<CallGraphNode *> &NodeVec = *CGI;<br class="">+<br class="">+      // Record that we've seen this set of functions so we don't run the pass<br class="">+      // twice.<br class="">+      for (auto *Elt : NodeVec)<br class="">+        Visited.insert(Elt->getFunctio<wbr class="">n());<br class="">+<br class="">+      // Copy the current SCC and increment past it so that the pass can hack<br class="">+      // on the SCC if it wants to without invalidating our iterator.<br class="">+      CurSCC.initialize(NodeVec);<br class="">+      ++CGI;<br class="">+<br class="">+      // If we've got all functions reachable from our chosen initial node,<br class="">+      // calculate the next node we need to search from now before parts of the<br class="">+      // graph are invalidated.<br class="">+      if (CGI.isAtEnd()) {<br class="">+        do<br class="">+          ++I;<br class="">+        while (I != E && Visited.count(I->first));<br class="">+      }<br class="">+<br class="">+      Changed |= runOnSCC(CurSCC, CG);<br class="">+    }<br class="">   }<br class="">+<br class="">   Changed |= doFinalization(CG);<br class="">   return Changed;<br class=""> }<br class=""><br class="">+bool CGPassManager::runOnSCC(CallGr<wbr class="">aphSCC &CurSCC, CallGraph &CG) {<br class="">+  bool Changed = false;<br class="">+<br class="">+  // At the top level, we run all the passes in this pass manager on the<br class="">+  // functions in this SCC.  However, we support iterative compilation in the<br class="">+  // case where a function pass devirtualizes a call to a function.  For<br class="">+  // example, it is very common for a function pass (often GVN or instcombine)<br class="">+  // to eliminate the addressing that feeds into a call.  With that improved<br class="">+  // information, we would like the call to be an inline candidate, infer<br class="">+  // mod-ref information etc.<br class="">+  //<br class="">+  // Because of this, we allow iteration up to a specified iteration count.<br class="">+  // This only happens in the case of a devirtualized call, so we only burn<br class="">+  // compile time in the case that we're making progress.  We also have a hard<br class="">+  // iteration count limit in case there is crazy code.<br class="">+  unsigned Iteration = 0;<br class="">+  bool DevirtualizedCall = false;<br class="">+  do {<br class="">+    LLVM_DEBUG(if (Iteration) dbgs()<br class="">+               << "  SCCPASSMGR: Re-visiting SCC, iteration #" << Iteration<br class="">+               << '\n');<br class="">+    DevirtualizedCall = false;<br class="">+    Changed |= RunAllPassesOnSCC(CurSCC, CG, DevirtualizedCall);<br class="">+  } while (Iteration++ < MaxIterations && DevirtualizedCall);<br class="">+<br class="">+  if (DevirtualizedCall)<br class="">+    LLVM_DEBUG(dbgs() << "  CGSCCPASSMGR: Stopped iteration after " << Iteration<br class="">+                      << " times, due to -max-cg-scc-iterations\n");<br class="">+<br class="">+  MaxSCCIterations.updateMax(Ite<wbr class="">ration);<br class="">+  return Changed;<br class="">+}<br class="">+<br class=""> /// Initialize CG<br class=""> bool CGPassManager::doInitializatio<wbr class="">n(CallGraph &CG) {<br class="">   bool Changed = false;<br class=""><br class="">Modified: llvm/trunk/test/Transforms/Inl<wbr class="">ine/always-inline.ll<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/always-inline.ll?rev=336419&r1=336418&r2=336419&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-pr<wbr class="">oject/llvm/trunk/test/Transfor<wbr class="">ms/Inline/always-inline.ll?<wbr class="">rev=336419&r1=336418&r2=<wbr class="">336419&view=diff</a><br class="">==============================<wbr class="">==============================<wbr class="">==================<br class="">--- llvm/trunk/test/Transforms/Inl<wbr class="">ine/always-inline.ll (original)<br class="">+++ llvm/trunk/test/Transforms/Inl<wbr class="">ine/always-inline.ll Fri Jul  6 01:04:47 2018<br class="">@@ -316,3 +316,10 @@ define void @outer14() {<br class="">   call void @inner14()<br class="">   ret void<br class=""> }<br class="">+<br class="">+define internal i32 @outer15() {<br class="">+; CHECK-LABEL: @outer15<br class="">+; CHECK: ret i32 1<br class="">+  %res = call i32 @inner1()<br class="">+  ret i32 %res<br class="">+}<br class=""><br class=""><br class="">______________________________<wbr class="">_________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-commits</a><u class=""></u><u class=""></u></p></blockquote></div><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br class="">______________________________<wbr class="">_________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-commits</a><u class=""></u><u class=""></u></p></blockquote></div><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div></div></div></blockquote></div><p class="MsoNormal"><u class=""></u> <u class=""></u></p></div></div></div></div></div></blockquote></div><br class=""></div>
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>