Util/slottracker.cpp
// Process the arguments, basic blocks, and instructions  of a function.
Process the arguments, basic blocks, and instructions  of a function.
Process the arguments basic blocks and instructions of a function .
void SlotTracker::processFunction() {
    ST_DEBUG("begin processFunction!\n");
    fNext = 0;
    for(Function::const_arg_iterator AI = TheFunction->arg_begin(),
            AE = TheFunction->arg_end(); AI != AE; ++AI)
        if (!AI->hasName())
            CreateFunctionSlot(AI);
    ST_DEBUG("Inserting Instructions:\n");
    SmallVector<std::pair<unsigned, MDNode*>, 4> MDForInst;
    for (Function::const_iterator BB = TheFunction->begin(),
            E = TheFunction->end(); BB != E; ++BB) {
        if (!BB->hasName())
            CreateFunctionSlot(BB);
        for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E;
                ++I) {
            if (!I->getType()->isVoidTy() && !I->hasName())
                CreateFunctionSlot(I);
            if (const CallInst *CI = dyn_cast<CallInst>(I)) {
                if (Function *F = CI->getCalledFunction())
                    if (F->getName().startswith("llvm."))
                        for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
                            if (MDNode *N = dyn_cast_or_null<MDNode>(I->getOperand(i)))
                                CreateMetadataSlot(N);
            }
            I->getAllMetadata(MDForInst);
            for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
                CreateMetadataSlot(MDForInst[i].second);
            MDForInst.clear();
        }
    }
    FunctionProcessed = true;
    ST_DEBUG("end processFunction!\n");
}
void SlotTracker :: processFunction ( ) { ST_DEBUG ( " \n " ) ; fNext = 0 ; for ( Function :: const_arg_iterator AI = TheFunction -> arg_begin ( ) , AE = TheFunction -> arg_end ( ) ; AI != AE ; ++ AI ) if ( ! AI -> hasName ( ) ) CreateFunctionSlot ( AI ) ; ST_DEBUG ( " \n " ) ; SmallVector < std :: pair < unsigned , MDNode * > , 4 > MDForInst ; for ( Function :: const_iterator BB = TheFunction -> begin ( ) , E = TheFunction -> end ( ) ; BB != E ; ++ BB ) { if ( ! BB -> hasName ( ) ) CreateFunctionSlot ( BB ) ; for ( BasicBlock :: const_iterator I = BB -> begin ( ) , E = BB -> end ( ) ; I != E ; ++ I ) { if ( ! I -> getType ( ) -> isVoidTy ( ) && ! I -> hasName ( ) ) CreateFunctionSlot ( I ) ; if ( const CallInst * CI = dyn_cast < CallInst > ( I ) ) { if ( Function * F = CI -> getCalledFunction ( ) ) if ( F -> getName ( ) . startswith ( " " ) ) for ( unsigned i = 0 , e = I -> getNumOperands ( ) ; i != e ; ++ i ) if ( MDNode * N = dyn_cast_or_null < MDNode > ( I -> getOperand ( i ) ) ) CreateMetadataSlot ( N ) ; } I -> getAllMetadata ( MDForInst ) ; for ( unsigned i = 0 , e = MDForInst . size ( ) ; i != e ; ++ i ) CreateMetadataSlot ( MDForInst [ i ] . second ) ; MDForInst . clear ( ) ; } } FunctionProcessed = true ; ST_DEBUG ( " \n " ) ; }
Process the arguments, basic blocks, and instructions  of a function.
Process the arguments basic blocks and instructions of a function .
// Add all the function arguments with no names. // Add all of the basic blocks and instructions with no names. // Intrinsics can directly use metadata. We allow direct calls to any // llvm.foo function here, because the target may not be linked into the // optimizer. // Process metadata attached with this instruction.