Skip to content

Commit f2d9588

Browse files
authored
Several minor fixes (#620)
1 parent 080770f commit f2d9588

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

dartagnan/src/main/java/com/dat3m/dartagnan/expression/integers/IntLiteral.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public int getValueAsInt() {
3131
return value.intValueExact();
3232
}
3333

34+
public long getValueAsLong() {
35+
return value.longValueExact();
36+
}
37+
3438
public boolean isOne() { return value.equals(BigInteger.ONE); }
3539
public boolean isZero() { return value.equals(BigInteger.ZERO); }
3640

dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/MemToReg.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ private void promoteAll(Function function, Matcher matcher) {
9797
if (event instanceof Load load) {
9898
final Register reg = load.getResultRegister();
9999
assert load.getUsers().isEmpty();
100-
load.replaceBy(EventFactory.newLocal(reg, expressions.makeCast(registers.get(access.offset), reg.getType())));
100+
load.replaceBy(EventFactory.newLocal(reg, expressions.makeCast(registers.get((int)access.offset), reg.getType())));
101101
loadCount++;
102102
}
103103
if (event instanceof Store store) {
104-
final Register reg = registers.get(access.offset);
104+
final Register reg = registers.get((int)access.offset);
105105
assert store.getUsers().isEmpty();
106106
store.replaceBy(EventFactory.newLocal(reg, expressions.makeCast(store.getMemValue(), reg.getType())));
107107
storeCount++;
@@ -142,14 +142,14 @@ private List<Type> getPrimitiveReplacementTypes(Alloc allocation) {
142142
}
143143

144144
// Invariant: base != null
145-
private record AddressOffset(RegWriter base, int offset) {
146-
private AddressOffset increase(int o) {
145+
private record AddressOffset(RegWriter base, long offset) {
146+
private AddressOffset increase(long o) {
147147
return o == 0 ? this : new AddressOffset(base, offset + o);
148148
}
149149
}
150150

151151
// Invariant: register != null
152-
private record RegisterOffset(Register register, int offset) {}
152+
private record RegisterOffset(Register register, long offset) {}
153153

154154
// Processes events in program order.
155155
// Returns a label, if it is program-ordered before the current event and its symbolic state was updated.
@@ -327,14 +327,14 @@ private void publishRegisters(Set<Register> registers) {
327327
}
328328

329329
private RegisterOffset matchGEP(Expression expression) {
330-
int sum = 0;
330+
long sum = 0;
331331
while (!(expression instanceof Register register)) {
332332
if (!(expression instanceof IntBinaryExpr bin) ||
333333
bin.getKind() != IntBinaryOp.ADD ||
334334
!(bin.getRight() instanceof IntLiteral offset)) {
335335
return null;
336336
}
337-
sum += offset.getValueAsInt();
337+
sum += offset.getValueAsLong();
338338
expression = bin.getLeft();
339339
}
340340
return new RegisterOffset(register, sum);

dartagnan/src/main/java/com/dat3m/dartagnan/program/processing/RemoveUnusedMemory.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ public void run(Program program) {
2525
program.getThreadEvents(RegReader.class).forEach(r -> r.transformExpressions(collector));
2626
// Also add MemoryObjects referenced by initial values (this does happen in Litmus code)
2727
for (MemoryObject obj : memory.getObjects()) {
28-
for (int field : obj.getStaticallyInitializedFields()) {
29-
if (obj.getInitialValue(field) instanceof MemoryObject memObj) {
30-
collector.memoryObjects.add(memObj);
31-
}
28+
for (Integer field : obj.getStaticallyInitializedFields()) {
29+
obj.getInitialValue(field).accept(collector);
3230
}
3331
}
3432
// FIXME: We should also traverse the program spec for references to memory objects

0 commit comments

Comments
 (0)