Search in sources :

Example 31 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class BranchReordering method run.

@Override
public void run(Program program) {
    Preconditions.checkArgument(!program.isUnrolled(), "Reordering should be performed before unrolling.");
    for (Thread t : program.getThreads()) {
        new ThreadReordering(t).run();
    }
    logger.info("Branches reordered");
    logger.info("{}: {}", DETERMINISTIC_REORDERING, reorderDeterministically);
}
Also used : Thread(com.dat3m.dartagnan.program.Thread)

Example 32 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class ConstantPropagation method run.

@Override
public void run(Program program) {
    Preconditions.checkArgument(program.isUnrolled(), "The program needs to be unrolled before constant propagation.");
    Preconditions.checkArgument(!program.isCompiled(), "Constant propagation needs to be run before compilation.");
    for (Thread thread : program.getThreads()) {
        run(thread);
    }
}
Also used : Thread(com.dat3m.dartagnan.program.Thread)

Example 33 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class DeadAssignmentElimination method run.

@Override
public void run(Program program) {
    this.program = program;
    logger.info("#Events before DSE: " + program.getEvents().size());
    for (Thread t : program.getThreads()) {
        eliminateDeadStores(t);
        t.clearCache();
    }
    program.clearCache(false);
    logger.info("#Events after DSE: " + program.getEvents().size());
}
Also used : Thread(com.dat3m.dartagnan.program.Thread)

Example 34 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class DeadAssignmentElimination method eliminateDeadStores.

private void eliminateDeadStores(Thread thread) {
    Set<Event> removed = new HashSet<>();
    // Registers that are used by other threads or assertions cannot be removed
    Set<Register> usedRegs = new HashSet<>();
    if (program.getAss() != null) {
        usedRegs.addAll(program.getAss().getRegs());
    }
    program.getCache().getEvents(FilterBasic.get(ASSERTION)).stream().filter(RegWriter.class::isInstance).map(RegWriter.class::cast).map(RegWriter::getResultRegister).forEach(usedRegs::add);
    program.getEvents().stream().filter(o -> !o.getThread().equals(thread)).filter(o -> o instanceof RegReaderData).forEach(o -> usedRegs.addAll(((RegReaderData) o).getDataRegs()));
    for (Event e : Lists.reverse(thread.getEvents())) {
        if (e instanceof RegWriter && !e.is(VISIBLE) && !usedRegs.contains(((RegWriter) e).getResultRegister())) {
            // Invisible RegWriters that write to an unused reg can get removed
            removed.add(e);
        }
        // An event that was not removed adds its dependencies to the used registers
        if (!removed.contains(e)) {
            if (e instanceof RegReaderData) {
                // Data & Ctrl dependencies
                usedRegs.addAll(((RegReaderData) e).getDataRegs());
            }
            if (e instanceof MemEvent) {
                // Address dependencies
                usedRegs.addAll(((MemEvent) e).getAddress().getRegs());
            }
        }
    }
    // Here is the actual removal
    Event pred = null;
    Event cur = thread.getEntry();
    while (cur != null) {
        if (removed.contains(cur) && !cur.is(Tag.NOOPT)) {
            cur.delete();
            cur = pred;
        }
        pred = cur;
        cur = cur.getSuccessor();
    }
}
Also used : Configuration(org.sosy_lab.common.configuration.Configuration) ASSERTION(com.dat3m.dartagnan.program.event.Tag.ASSERTION) Set(java.util.Set) Thread(com.dat3m.dartagnan.program.Thread) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Tag(com.dat3m.dartagnan.program.event.Tag) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) Logger(org.apache.logging.log4j.Logger) VISIBLE(com.dat3m.dartagnan.program.event.Tag.VISIBLE) Program(com.dat3m.dartagnan.program.Program) Event(com.dat3m.dartagnan.program.event.core.Event) RegReaderData(com.dat3m.dartagnan.program.event.core.utils.RegReaderData) Register(com.dat3m.dartagnan.program.Register) RegWriter(com.dat3m.dartagnan.program.event.core.utils.RegWriter) LogManager(org.apache.logging.log4j.LogManager) FilterBasic(com.dat3m.dartagnan.program.filter.FilterBasic) InvalidConfigurationException(org.sosy_lab.common.configuration.InvalidConfigurationException) Register(com.dat3m.dartagnan.program.Register) RegWriter(com.dat3m.dartagnan.program.event.core.utils.RegWriter) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) RegReaderData(com.dat3m.dartagnan.program.event.core.utils.RegReaderData) MemEvent(com.dat3m.dartagnan.program.event.core.MemEvent) Event(com.dat3m.dartagnan.program.event.core.Event) HashSet(java.util.HashSet)

Example 35 with Thread

use of com.dat3m.dartagnan.program.Thread in project Dat3M by hernanponcedeleon.

the class DeadCodeElimination method run.

@Override
public void run(Program program) {
    Preconditions.checkArgument(!program.isUnrolled(), "Dead code elimination should be performed before unrolling.");
    logger.info("#Events before DCE: " + program.getEvents().size());
    int id = 0;
    for (Thread t : program.getThreads()) {
        eliminateDeadCode(t, id);
        t.clearCache();
        id = t.getExit().getOId() + 1;
    }
    program.clearCache(false);
    logger.info("#Events after DCE: " + program.getEvents().size());
}
Also used : Thread(com.dat3m.dartagnan.program.Thread)

Aggregations

Thread (com.dat3m.dartagnan.program.Thread)48 Event (com.dat3m.dartagnan.program.event.core.Event)27 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)13 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)11 LogManager (org.apache.logging.log4j.LogManager)10 Logger (org.apache.logging.log4j.Logger)10 BooleanFormula (org.sosy_lab.java_smt.api.BooleanFormula)9 BooleanFormulaManager (org.sosy_lab.java_smt.api.BooleanFormulaManager)9 Program (com.dat3m.dartagnan.program.Program)8 Tag (com.dat3m.dartagnan.program.event.Tag)8 Configuration (org.sosy_lab.common.configuration.Configuration)8 InvalidConfigurationException (org.sosy_lab.common.configuration.InvalidConfigurationException)8 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)7 Collectors (java.util.stream.Collectors)7 Context (com.dat3m.dartagnan.verification.Context)6 Preconditions (com.google.common.base.Preconditions)6 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)5 Options (org.sosy_lab.common.configuration.Options)5 Utils.generalEqual (com.dat3m.dartagnan.expression.utils.Utils.generalEqual)4 RegWriter (com.dat3m.dartagnan.program.event.core.utils.RegWriter)4