summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r--src/passes/OptimizeInstructions.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 792cf6235..6a528d74f 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -1831,6 +1831,12 @@ struct OptimizeInstructions
void visitStructGet(StructGet* curr) {
skipNonNullCast(curr->ref, curr);
trapOnNull(curr, curr->ref);
+ // Relax acquire loads of unshared fields to unordered because they cannot
+ // synchronize with other threads.
+ if (curr->order == MemoryOrder::AcqRel && curr->ref->type.isRef() &&
+ !curr->ref->type.getHeapType().isShared()) {
+ curr->order = MemoryOrder::Unordered;
+ }
}
void visitStructSet(StructSet* curr) {
@@ -1847,6 +1853,13 @@ struct OptimizeInstructions
optimizeStoredValue(curr->value, fields[curr->index].getByteSize());
}
}
+
+ // Relax release stores of unshared fields to unordered because they cannot
+ // synchronize with other threads.
+ if (curr->order == MemoryOrder::AcqRel && curr->ref->type.isRef() &&
+ !curr->ref->type.getHeapType().isShared()) {
+ curr->order = MemoryOrder::Unordered;
+ }
}
void visitArrayNew(ArrayNew* curr) {