Пример #1
0
static bool handleParams(LLVMNode *callNode, unsigned vararg,
                         LLVMDGParameters *params,
                         DefMap *df, DefMap *subgraph_df)
{
    bool changed = false;

    // operand[0] is the called func
    for (int i = 1, e = callNode->getOperandsNum(); i < e; ++i) {
        LLVMNode *op = callNode->getOperand(i);
        if (!op)
            continue;

        if (!op->isPointerTy())
            continue;

        LLVMDGParameter *p = params->find(op->getKey());
        if (!p) {
#ifdef DEBUG_ENABLED
            if (i - 1 < (int) vararg)
                DBG("ERR: no actual param for " << *op->getKey());
#endif
            continue;
        }

        changed |= handleParam(op, p->out, df, subgraph_df);
    }

    return changed;
}
Пример #2
0
void LLVMDGVerifier::checkGraph(llvm::Function *F, LLVMDependenceGraph *g)
{
    using namespace llvm;

    LLVMNode *entry = g->getEntry();
    if (!entry) {
        fault("has no entry for %s", F->getName().data());
        return;
    }

    const llvm::Function *func = dyn_cast<Function>(entry->getKey());
    if (!func) {
        fault("key in entry node is not a llvm::Function");
        return;
    }

    size_t a, b;
    a = g->getBlocks().size();
    b = func->size();
    if (a != b)
        fault("have constructed %lu BBlocks but function has %lu basic blocks", a, b);

    for (BasicBlock& llvmBB : *F) {
        LLVMBBlock *BB = g->getBlocks()[&llvmBB];
        if (!BB) {
            fault("missing BasicBlock");
            errs() << llvmBB << "\n";
        } else
            checkBBlock(&llvmBB, BB);
    }
}
Пример #3
0
void LLVMDGVerifier::checkBBlock(const llvm::BasicBlock *llvmBB, LLVMBBlock *BB)
{
    using namespace llvm;
    auto BBIT = BB->getNodes().begin();

    for (const Instruction& I : *llvmBB) {
        LLVMNode *node = *BBIT;

        // check if we have the CFG edges set
        if (node->getKey() != &I)
            fault("wrong node in BB");

        checkNode(&I, node);
        ++BBIT;
    }

    // FIXME: check successors and predecessors
}