[PATCH] D18576: Initial implementation of optimization bisect

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 13 15:28:11 PDT 2016


andrew.w.kaylor added a comment.

In http://reviews.llvm.org/D18576#399046, @MatzeB wrote:

> We have to count how many passes we skipped/did not skip and compare that against the bisect number. This is global information.


Is there a good way to get the context from a CallGraphSCC?  This is what I came up with:

  static LLVMContext *getCGNodeContext(CallGraphNode *Node) {
    Function *F = Node->getFunction();
    if (F)
      return &F->getContext();
    for (CallGraphNode::iterator I = Node->begin(), E = Node->end(); I != E;
         ++I) {
      if (I->first)
        return &cast<Function>(I->first)->getContext();
      Function *CalledFn = I->second->getFunction();
      // A null CalledFn indicates a call to an external node.
      if (!CalledFn)
        continue;
      return &(CalledFn->getContext());
    }
  }
  
  bool CallGraphSCCPass::skipSCC(CallGraphSCC &SCC) const {
    CallGraphNode *Node = *(SCC.begin());
    assert(Node);
    if (!Node)
      return false;
    LLVMContext *Context = nullptr;
    for (CallGraphNode *Node : SCC) {
      Context = getCGNodeContext(Node);
      if (Context)
        break;
    }
    assert(Context);
    // If we can't get the context, assume the pass can't be skipped.
    if (!Context)
      return false;
    return !Context->getOptBisect().shouldRunPass(this, &SCC);
  }

It feels awful.  Is there a better way to do that?


Repository:
  rL LLVM

http://reviews.llvm.org/D18576





More information about the llvm-commits mailing list