Search in sources :

Example 11 with AliasAnalysis

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

the class AnalysisTest method program5.

private void program5(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.getOrNewObject("x");
    MemoryObject y = b.getOrNewObject("y");
    MemoryObject z = b.getOrNewObject("z");
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    b.addChild(0, newLocal(r0, y));
    Store e0 = newStore(r0);
    b.addChild(0, e0);
    b.addChild(0, newLocal(r0, mult(x, 0)));
    Store e1 = newStore(x);
    b.addChild(0, e1);
    Store e2 = newStore(y);
    b.addChild(0, e2);
    Store e3 = newStore(z);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    // precisely no
    assertAlias(expect[0], a, e0, e1);
    // precisely must
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 12 with AliasAnalysis

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

the class AnalysisTest method program1.

private void program1(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.newObject("x", 3);
    x.setInitialValue(0, x);
    b.initThread(0);
    Store e0 = newStore(plus(x, 1));
    b.addChild(0, e0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    Load e1 = newLoad(r0, x);
    b.addChild(0, e1);
    Store e2 = newStore(r0);
    b.addChild(0, e2);
    Store e3 = newStore(plus(r0, 1), r0);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    assertAlias(expect[0], a, e0, e1);
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 13 with AliasAnalysis

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

the class AliasAnalysisTest method program0.

private void program0(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder();
    MemoryObject x = b.newObject("x", 2);
    MemoryObject y = b.getOrNewObject("y");
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", -1);
    // this is undefined behavior in C11
    // the expression does not match a sum, but x occurs in it
    b.addChild(0, newLocal(r0, mult(x, 1)));
    Store e0 = newStore(r0);
    b.addChild(0, e0);
    Store e1 = newStore(plus(r0, 1));
    b.addChild(0, e1);
    Store e2 = newStore(x);
    b.addChild(0, e2);
    Store e3 = newStore(y);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    // precisely no
    assertAlias(expect[0], a, e0, e1);
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 14 with AliasAnalysis

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

the class AnalysisTest method program4.

private void program4(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.getOrNewObject("x");
    MemoryObject y = b.getOrNewObject("y");
    MemoryObject z = b.getOrNewObject("z");
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    b.addChild(0, newLocal(r0, mult(x, 0)));
    b.addChild(0, newLocal(r0, y));
    Store e0 = newStore(r0);
    b.addChild(0, e0);
    Store e1 = newStore(x);
    b.addChild(0, e1);
    Store e2 = newStore(y);
    b.addChild(0, e2);
    Store e3 = newStore(z);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    // precisely no
    assertAlias(expect[0], a, e0, e1);
    // precisely must
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Example 15 with AliasAnalysis

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

the class AnalysisTest method program0.

private void program0(Alias method, Result... expect) throws InvalidConfigurationException {
    ProgramBuilder b = new ProgramBuilder(SourceLanguage.LITMUS);
    MemoryObject x = b.newObject("x", 2);
    MemoryObject y = b.getOrNewObject("y");
    b.initThread(0);
    Register r0 = b.getOrCreateRegister(0, "r0", ARCH_PRECISION);
    // this is undefined behavior in C11
    // the expression does not match a sum, but x occurs in it
    b.addChild(0, newLocal(r0, mult(x, 1)));
    Store e0 = newStore(r0);
    b.addChild(0, e0);
    Store e1 = newStore(plus(r0, 1));
    b.addChild(0, e1);
    Store e2 = newStore(x);
    b.addChild(0, e2);
    Store e3 = newStore(y);
    b.addChild(0, e3);
    AliasAnalysis a = analyze(b, method);
    // precisely no
    assertAlias(expect[0], a, e0, e1);
    assertAlias(expect[1], a, e0, e2);
    assertAlias(expect[2], a, e1, e2);
    assertAlias(expect[3], a, e0, e3);
    assertAlias(expect[4], a, e1, e3);
    assertAlias(expect[5], a, e2, e3);
}
Also used : Register(com.dat3m.dartagnan.program.Register) ProgramBuilder(com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder) MemoryObject(com.dat3m.dartagnan.program.memory.MemoryObject) AliasAnalysis(com.dat3m.dartagnan.program.analysis.AliasAnalysis)

Aggregations

AliasAnalysis (com.dat3m.dartagnan.program.analysis.AliasAnalysis)20 ProgramBuilder (com.dat3m.dartagnan.parsers.program.utils.ProgramBuilder)12 Register (com.dat3m.dartagnan.program.Register)12 MemoryObject (com.dat3m.dartagnan.program.memory.MemoryObject)12 MemEvent (com.dat3m.dartagnan.program.event.core.MemEvent)7 Tuple (com.dat3m.dartagnan.wmm.utils.Tuple)7 Event (com.dat3m.dartagnan.program.event.core.Event)6 TupleSet (com.dat3m.dartagnan.wmm.utils.TupleSet)5 WmmAnalysis (com.dat3m.dartagnan.wmm.analysis.WmmAnalysis)4 ExecutionAnalysis (com.dat3m.dartagnan.program.analysis.ExecutionAnalysis)2 Load (com.dat3m.dartagnan.program.event.core.Load)2 Store (com.dat3m.dartagnan.program.event.core.Store)2 EndAtomic (com.dat3m.dartagnan.program.event.lang.svcomp.EndAtomic)2 FilterAbstract (com.dat3m.dartagnan.program.filter.FilterAbstract)2 IExpr (com.dat3m.dartagnan.expression.IExpr)1 Utils (com.dat3m.dartagnan.expression.utils.Utils)1 Tag (com.dat3m.dartagnan.program.event.Tag)1 Init (com.dat3m.dartagnan.program.event.core.Init)1 FilterBasic (com.dat3m.dartagnan.program.filter.FilterBasic)1 FilterIntersection (com.dat3m.dartagnan.program.filter.FilterIntersection)1