Skip to content

Commit 76d01bc

Browse files
ThomasHaashernanponcedeleon
authored andcommitted
TBAA implements AliasAnalysis now.
Added TBAA as combined analysis to other alias analyses (for testing)
1 parent 1029e06 commit 76d01bc

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/AliasAnalysis.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static AliasAnalysis fromConfig(Program program, Configuration config) throws In
4747
throw new UnsupportedOperationException("Alias method not recognized");
4848
}
4949
a = new CombinedAliasAnalysis(a, EqualityAliasAnalysis.fromConfig(program, config));
50+
a = new CombinedAliasAnalysis(a, TBAA.fromConfig(config));
5051
if (Arch.supportsVirtualAddressing(program.getArch())) {
5152
a = VirtualAliasAnalysis.wrap(a);
5253
}

dartagnan/src/main/java/com/dat3m/dartagnan/program/analysis/alias/TBAA.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,35 @@
11
package com.dat3m.dartagnan.program.analysis.alias;
22

3+
import com.dat3m.dartagnan.program.event.core.MemoryCoreEvent;
34
import com.dat3m.dartagnan.program.event.metadata.Metadata;
5+
import org.sosy_lab.common.configuration.Configuration;
46

57
import java.util.List;
68
import java.util.stream.Collectors;
79

8-
public final class TBAA {
10+
public final class TBAA implements AliasAnalysis {
911

1012
private TBAA() {}
1113

14+
public static AliasAnalysis fromConfig(Configuration config) {
15+
return new TBAA();
16+
}
17+
18+
@Override
19+
public boolean mustAlias(MemoryCoreEvent a, MemoryCoreEvent b) {
20+
return false;
21+
}
22+
23+
@Override
24+
public boolean mayAlias(MemoryCoreEvent a, MemoryCoreEvent b) {
25+
final AccessTag aTag = a.getMetadata(AccessTag.class);
26+
final AccessTag bTag = b.getMetadata(AccessTag.class);
27+
return aTag == null || bTag == null || canAlias(aTag, bTag);
28+
}
29+
30+
// ================================================================================================
31+
// Helper methods
32+
1233
public static boolean canAlias(AccessTag x, AccessTag y) {
1334
final TypeOffset xAccess = new TypeOffset(x.base(), x.offset());
1435
final TypeOffset yAccess = new TypeOffset(y.base(), y.offset());
@@ -40,7 +61,7 @@ public static TypeOffset getImmediateParent(TypeOffset typeOffset) {
4061
final TypeOffset cur = structType.offsets().get(i);
4162
final TypeOffset next = (i + 1) < structType.offsets().size() ? structType.offsets().get(i + 1) : null;
4263

43-
if (next == null || next.offset() < typeOffset.offset()) {
64+
if (next == null || next.offset() > typeOffset.offset()) {
4465
return new TypeOffset(cur.type(), cur.offset() - typeOffset.offset());
4566
}
4667
}

0 commit comments

Comments
 (0)