Exemple #1
0
  std::string getEdgeAttributes(RegionNode *srcNode,
                                GraphTraits<RegionInfo *>::ChildIteratorType CI,
                                RegionInfo *G) {
    RegionNode *destNode = *CI;

    if (srcNode->isSubRegion() || destNode->isSubRegion())
      return "";

    // In case of a backedge, do not use it to define the layout of the nodes.
    BasicBlock *srcBB = srcNode->getNodeAs<BasicBlock>();
    BasicBlock *destBB = destNode->getNodeAs<BasicBlock>();

    Region *R = G->getRegionFor(destBB);

    while (R && R->getParent())
      if (R->getParent()->getEntry() == destBB)
        R = R->getParent();
      else
        break;

    if (R && R->getEntry() == destBB && R->contains(srcBB))
      return "constraint=false";

    return "";
  }
Exemple #2
0
		void JSEdgeRemovalPass::padExitBlocks(RegionInfo& ri, Region* target) {
			for(Region::element_iterator i = target->element_begin(), e = target->element_end(); i != e; ++i) {
				RegionNode* rn = (RegionNode*)(*i);
				if(rn->isSubRegion()) {
					Region* subRegion = rn->getNodeAs<Region>();
					padExitBlocks(ri, subRegion);
				}
			}
			BasicBlock* exit = target->getExit();
			if(exit != NULL) {
				//we need to split the block into two parts to give padding space
				//Keep the phi nodes and landing pad instructions in the original
				//block and push all instructions into the new block below. That
				//way we have convergence yet space to move elements up onto a
				//given path if it turns out that the given instruction can't 

				//32 is a good number
				unsigned count = 0;
				SmallVector<BasicBlock*,32> elements;
				for(pred_iterator PI = pred_begin(exit), E = pred_end(exit); PI != E; ++PI) {
					BasicBlock* bb = *PI;
					if(target->contains(bb)) {
						elements.push_back(bb);
					}
					count++;
				}
				if(elements.size() > 0 && count != elements.size()) { 
					BasicBlock* update = SplitBlockPredecessors(exit, elements, "Pad", this);
					target->replaceExit(update);
				}
				//ri.splitBlock(update, exit);
			}

		}
Exemple #3
0
/// \brief Helper to call buildExtractionBlockSet with a RegionNode.
static SetVector<BasicBlock *> buildExtractionBlockSet(const RegionNode &RN) {
  if (!RN.isSubRegion())
    // Just a single BasicBlock.
    return buildExtractionBlockSet(RN.getNodeAs<BasicBlock>());

  const Region &R = *RN.getNodeAs<Region>();

  return buildExtractionBlockSet(R.block_begin(), R.block_end());
}