|
1 | 1 | package com.dat3m.dartagnan.program.analysis.alias; |
2 | 2 |
|
| 3 | +import com.dat3m.dartagnan.program.event.core.MemoryCoreEvent; |
3 | 4 | import com.dat3m.dartagnan.program.event.metadata.Metadata; |
| 5 | +import org.sosy_lab.common.configuration.Configuration; |
4 | 6 |
|
5 | 7 | import java.util.List; |
6 | 8 | import java.util.stream.Collectors; |
7 | 9 |
|
8 | | -public final class TBAA { |
| 10 | +public final class TBAA implements AliasAnalysis { |
9 | 11 |
|
10 | 12 | private TBAA() {} |
11 | 13 |
|
| 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 | + |
12 | 33 | public static boolean canAlias(AccessTag x, AccessTag y) { |
13 | 34 | final TypeOffset xAccess = new TypeOffset(x.base(), x.offset()); |
14 | 35 | final TypeOffset yAccess = new TypeOffset(y.base(), y.offset()); |
@@ -40,7 +61,7 @@ public static TypeOffset getImmediateParent(TypeOffset typeOffset) { |
40 | 61 | final TypeOffset cur = structType.offsets().get(i); |
41 | 62 | final TypeOffset next = (i + 1) < structType.offsets().size() ? structType.offsets().get(i + 1) : null; |
42 | 63 |
|
43 | | - if (next == null || next.offset() < typeOffset.offset()) { |
| 64 | + if (next == null || next.offset() > typeOffset.offset()) { |
44 | 65 | return new TypeOffset(cur.type(), cur.offset() - typeOffset.offset()); |
45 | 66 | } |
46 | 67 | } |
|
0 commit comments