Beispiel #1
0
 static void reset()
 {
   swapCount() = 0;
   copyCount() = 0;
   constructCount() = 0;
   destructCount() = 0;
 }
Beispiel #2
0
 swap_test_class(const swap_test_class& arg)
 :
 m_data(arg.m_data)
 {
   ++copyCount();
   ++destructCount();
 }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AggregateCopyPropagation::RemovedDeadCopySetCalls() {
    // We count how many times each copy is used in the function.
    // All copies that are not used anymore can be removed,
    // allowing Dead Code Elimination to do it's job.
    List<int> copyCount(infoList_.Count());

    for(int i = 0; i < infoList_.Count(); i++) {
        copyCount.Add(0);
    }

    // Scan all instructions in the function.
    for(auto block = funct_->FirstBlock(); block; block = block->NextBlock()) {
        for(auto instr = block->FirstInstruction(); instr; 
            instr = instr->NextInstruction()) {
            // We check 'store', 'load' and 'call' instructions only,
            // because they're the ones that can access the copy.
            if(auto loadInstr = instr->As<LoadInstr>()) {
                VisitedDict visited;
                MarkUsedCopies(loadInstr->SourceOp(), 
                               copyCount, visited);
            }
            else if(auto storeInstr = instr->As<StoreInstr>()) {
                VisitedDict visited1;
                MarkUsedCopies(storeInstr->DestinationOp(), copyCount,
                               visited1, true /* ignoreLocals */);
                VisitedDict visited2;
                MarkUsedCopies(storeInstr->SourceOp(), copyCount,
                               visited2, true /* ignoreLocals */);
            }
            else if(auto callInstr = instr->As<CallInstr>()) {
                for(int i = 0; i < callInstr->ArgumentCount(); i++) {
                    VisitedDict visited;
                    MarkUsedCopies(callInstr->GetArgument(i), 
                                   copyCount, visited);
                }
            }
        }
    }

    // Remove any copy that is definitely dead.
    for(int i = 0; i < copyCount.Count(); i++) {
        if((copyCount[i] - infoList_[i].Replacements) < 2) {
            infoList_[i].CopySetCall->RemoveFromBlock(true /* free */);
        }
    }
}
Beispiel #4
0
 static unsigned int copy_count(){ return copyCount(); }
Beispiel #5
0
 swap_test_class& operator=(const swap_test_class& arg)
 {
   m_data = arg.m_data;
   ++copyCount();
   return *this;
 }