[PATCH] D24225: [LCG] Add the necessary functionality to the LazyCallGraph to support inlining.

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 23:48:20 PDT 2016


sanjoy added a comment.

Hi Chandler,

I've not yet had a chance to look at this in detail, so I only have some superficial comments inline.  However, I don't (yet! :) ) believe you when you say that inlining only does the three trivial transforms you outlined above.  Because `InlineFunction` does some basic simplification I think it can introduce new SCCs.  For instance, if I run `opt -always-inline` (and nothing else) on

  define void @f(void()* %p) alwaysinline {
    call void %p()
    ret void
  }
  
  define void @g() {
    call void @f(void()* @h)
    ret void
  }
  
  define void @h() {
    call void @g()
    ret void
  }

I get

  ; ModuleID = 'inl.ll'
  source_filename = "inl.ll"
  
  ; Function Attrs: alwaysinline
  define void @f(void ()* %p) #0 {
    call void %p()
    ret void
  }
  
  define void @g() {
    call void @h()
    ret void
  }
  
  define void @h() {
    call void @g()
    ret void
  }
  
  attributes #0 = { alwaysinline }

That is, we form a //new// SCC containing `@g` and `@h`.


================
Comment at: lib/Analysis/LazyCallGraph.cpp:1215
@@ -1214,3 +1214,3 @@
   // Insert the resulting postorder sequence into the global graph postorder
   // sequence before the current RefSCC in that sequnece. The idea being that
   // this RefSCC is the target of the reference edge removed, and thus has
----------------
Nit: spelling of sequnece 

================
Comment at: lib/Analysis/LazyCallGraph.cpp:1302
@@ +1301,3 @@
+  Parents.clear();
+  for (RefSCC *ParentRC : OldParents)
+    for (SCC *ParentC : ParentRC->SCCs)
----------------
Can we put this logic inside `connectRefSCC` ?

================
Comment at: lib/Analysis/LazyCallGraph.cpp:1413
@@ +1412,3 @@
+  // an index map.
+  auto RENI = std::find(RefSCCEntryNodes.begin(), RefSCCEntryNodes.end(), &F);
+  if (RENI != RefSCCEntryNodes.end())
----------------
`llvm::find`?

================
Comment at: lib/Analysis/LazyCallGraph.cpp:1496
@@ -1495,3 +1655,3 @@
 
   // For the SCCs where we fine no child SCCs, add them to the leaf list.
   if (IsLeaf)
----------------
Nit: s/fine/find/


https://reviews.llvm.org/D24225





More information about the llvm-commits mailing list