[PATCH] D89188: [CallGraphUpdater][FIX] Do not attempt to update unreachable functions

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 10 07:46:25 PDT 2020


jdoerfert created this revision.
jdoerfert added reviewers: lebedev.ri, asbirlea, aeubanks, sstefan1, uenoku.
Herald added subscribers: bollu, hiraditya.
Herald added a project: LLVM.
jdoerfert requested review of this revision.

In the sqlite3 build, under certain conditions, we ended up with an CG
update order in which an internal function ended up being unreachable
before `CallGraphUpdate::reanalyzeFunction` was called on it. That
resulted in a segfault as the function did not belong to any SCC
anymore. We now detect this and avoid to reanalyze such unreachable
functions.

I failed to simplify the 1.9MB sqlite3.bc file as conversion into .ll,
e.g., as performed by llvm-reduce, causes the problem to disappear.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89188

Files:
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp


Index: llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
+++ llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
@@ -92,7 +92,10 @@
   } else if (LCG) {
     LazyCallGraph::Node &N = LCG->get(Fn);
     LazyCallGraph::SCC *C = LCG->lookupSCC(N);
-    updateCGAndAnalysisManagerForCGSCCPass(*LCG, *C, N, *AM, *UR, *FAM);
+    // If this function ended up outside of an SCC, through prior updates, we
+    // cannot reanalyze it, nor is it necessary.
+    if (C)
+      updateCGAndAnalysisManagerForCGSCCPass(*LCG, *C, N, *AM, *UR, *FAM);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89188.297413.patch
Type: text/x-patch
Size: 657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201010/8279ca6f/attachment.bin>


More information about the llvm-commits mailing list