Search in sources :

Example 1 with Context

use of com.dat3m.dartagnan.verification.Context in project Dat3M by hernanponcedeleon.

the class EndAtomic method runLocalAnalysis.

@Override
public void runLocalAnalysis(Program program, Context context) {
    // ===== Temporary fix to rematch atomic blocks correctly =====
    BranchEquivalence eq = context.requires(BranchEquivalence.class);
    List<Event> begins = this.thread.getEvents().stream().filter(x -> x instanceof BeginAtomic && eq.isReachableFrom(x, this)).collect(Collectors.toList());
    this.begin = (BeginAtomic) begins.get(begins.size() - 1);
    // =======================================================
    findEnclosedEvents(eq);
}
Also used : SVCOMPATOMIC(com.dat3m.dartagnan.program.event.Tag.SVCOMP.SVCOMPATOMIC) BranchEquivalence(com.dat3m.dartagnan.program.analysis.BranchEquivalence) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) RMW(com.dat3m.dartagnan.program.event.Tag.RMW) Context(com.dat3m.dartagnan.verification.Context) List(java.util.List) Logger(org.apache.logging.log4j.Logger) EventVisitor(com.dat3m.dartagnan.program.event.visitors.EventVisitor) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Program(com.dat3m.dartagnan.program.Program) Event(com.dat3m.dartagnan.program.event.core.Event) Preconditions(com.google.common.base.Preconditions) Comparator(java.util.Comparator) LogManager(org.apache.logging.log4j.LogManager) BranchEquivalence(com.dat3m.dartagnan.program.analysis.BranchEquivalence) Event(com.dat3m.dartagnan.program.event.core.Event)

Example 2 with Context

use of com.dat3m.dartagnan.verification.Context in project Dat3M by hernanponcedeleon.

the class AnalysisTest method dependencyMustOverride.

@Test
public void dependencyMustOverride() throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    Register r1 = b.getOrCreateRegister(0, "r1", ARCH_PRECISION);
    Register r2 = b.getOrCreateRegister(0, "r2", ARCH_PRECISION);
    Label alt = b.getOrCreateLabel("alt");
    b.addChild(0, newJump(new BNonDet(ARCH_PRECISION), alt));
    Local e0 = newLocal(r0, value(1));
    b.addChild(0, e0);
    Local e1 = newLocal(r1, r0);
    b.addChild(0, e1);
    Label join = b.getOrCreateLabel("join");
    b.addChild(0, newGoto(join));
    b.addChild(0, alt);
    Local e2 = newLocal(r1, value(2));
    b.addChild(0, e2);
    b.addChild(0, join);
    Local e3 = newLocal(r2, r0);
    b.addChild(0, e3);
    Local e4 = newLocal(r2, r1);
    b.addChild(0, e4);
    Local e5 = newLocal(r0, r2);
    b.addChild(0, e5);
    Program program = b.build();
    LoopUnrolling.newInstance().run(program);
    Compilation.newInstance().run(program);
    Configuration config = Configuration.defaultConfiguration();
    Context context = Context.create();
    context.register(BranchEquivalence.class, BranchEquivalence.fromConfig(program, config));
    context.register(ExecutionAnalysis.class, ExecutionAnalysis.fromConfig(program, context, config));
    Dependency dep = Dependency.fromConfig(program, context, config);
    assertTrue(dep.of(e1, r0).initialized);
    assertList(dep.of(e1, r0).may, e0);
    assertList(dep.of(e1, r0).must, e0);
    assertFalse(dep.of(e3, r0).initialized);
    assertList(dep.of(e3, r0).may, e0);
    assertList(dep.of(e3, r0).must, e0);
    assertTrue(dep.of(e4, r1).initialized);
    assertList(dep.of(e4, r1).may, e1, e2);
    assertList(dep.of(e4, r1).must, e1, e2);
    assertTrue(dep.of(e5, r2).initialized);
    assertList(dep.of(e5, r2).may, e4);
    assertList(dep.of(e5, r2).must, e4);
}
Also used : Context(com.dat3m.dartagnan.verification.Context) Program(com.dat3m.dartagnan.program.Program) Configuration(org.sosy_lab.common.configuration.Configuration) Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) Dependency(com.dat3m.dartagnan.program.analysis.Dependency) Test(org.junit.Test)

Aggregations

Program (com.dat3m.dartagnan.program.Program)2 Context (com.dat3m.dartagnan.verification.Context)2 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)1 Register (com.dat3m.dartagnan.program.Register)1 BranchEquivalence (com.dat3m.dartagnan.program.analysis.BranchEquivalence)1 Dependency (com.dat3m.dartagnan.program.analysis.Dependency)1 RMW (com.dat3m.dartagnan.program.event.Tag.RMW)1 SVCOMPATOMIC (com.dat3m.dartagnan.program.event.Tag.SVCOMP.SVCOMPATOMIC)1 Event (com.dat3m.dartagnan.program.event.core.Event)1 EventVisitor (com.dat3m.dartagnan.program.event.visitors.EventVisitor)1 Preconditions (com.google.common.base.Preconditions)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Test (org.junit.Test)1