Skip to content

Commit 9aa43f3

Browse files
committed
Fix atomic ordering accessor
Use the derived ==. Providing our own causes a cyclic dependency on the ordering -> LLVM map which causes crashes on recursive initial accesses to the dictionary.
1 parent 94e8eaa commit 9aa43f3

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Sources/LLVM/IRBuilder.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,8 @@ public enum AtomicOrdering: Comparable {
200200
.sequentiallyConsistent: LLVMAtomicOrderingSequentiallyConsistent,
201201
]
202202

203-
public static func ==(lhs: AtomicOrdering, rhs: AtomicOrdering) -> Bool {
204-
return lhs.llvm == rhs.llvm
205-
}
206-
203+
/// Returns whether the left atomic ordering is strictly weaker than the
204+
/// right atomic order.
207205
public static func <(lhs: AtomicOrdering, rhs: AtomicOrdering) -> Bool {
208206
return lhs.llvm.rawValue < rhs.llvm.rawValue
209207
}

Tests/LLVMTests/IRBuilderSpec.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ class IRBuilderSpec : XCTestCase {
223223
// CONTROLFLOW-NEXT: store i64 1, i64* %var
224224
builder.buildStore(IntType.int64.constant(1), to: variable)
225225

226+
// CONTROLFLOW-NEXT: store volatile i64 1, i64* %var
227+
builder.buildStore(IntType.int64.constant(1), to: variable, volatile: true)
228+
229+
// CONTROLFLOW-NEXT: store atomic i64 1, i64* %var
230+
builder.buildStore(IntType.int64.constant(1), to: variable, ordering: .sequentiallyConsistent)
231+
226232
// CONTROLFLOW-NEXT: %0 = load i64, i64* %var
227233
let load = builder.buildLoad(variable)
228234

0 commit comments

Comments
 (0)