Skip to content

Commit bf3302d

Browse files
Only generate AcqRel SafeHeap load methods when --relaxed-atomics is enabled (#8193)
The new tests don't contain the string `AR` or `acqrel` for the atomic load methods that are generated. Note that the safe load function names are still changed compared to before #8169 but I assume that no-one else relies on the names that we pick. Part of #8165.
1 parent 653c164 commit bf3302d

File tree

4 files changed

+33694
-3
lines changed

4 files changed

+33694
-3
lines changed

src/passes/SafeHeap.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ struct SafeHeap : public Pass {
220220
void addGlobals(Module* module, FeatureSet features) {
221221
// load funcs
222222
Load load;
223+
std::vector<MemoryOrder> memoryOrdersToGenerate(
224+
features.hasRelaxedAtomics()
225+
? std::initializer_list<MemoryOrder>{MemoryOrder::Unordered,
226+
MemoryOrder::AcqRel,
227+
MemoryOrder::SeqCst}
228+
: std::initializer_list<MemoryOrder>{MemoryOrder::Unordered,
229+
MemoryOrder::SeqCst});
223230
for (Type type : {Type::i32, Type::i64, Type::f32, Type::f64, Type::v128}) {
224231
if (type == Type::v128 && !features.hasSIMD()) {
225232
continue;
@@ -243,9 +250,8 @@ struct SafeHeap : public Pass {
243250
if (align > bytes) {
244251
continue;
245252
}
246-
for (auto memoryOrder : {MemoryOrder::Unordered,
247-
MemoryOrder::AcqRel,
248-
MemoryOrder::SeqCst}) {
253+
254+
for (MemoryOrder memoryOrder : memoryOrdersToGenerate) {
249255
load.order = memoryOrder;
250256
if (load.isAtomic() &&
251257
!isPossibleAtomicOperation(

0 commit comments

Comments
 (0)