Skip to content

Commit 4862129

Browse files
kateinoigakukunrunner
authored andcommitted
[wasm][stdlib] HACK: Workaround for the bad stacksave codegen in LLVM
The LLVM backend generates bad code for some code using `llvm.stacksave` intrinsics. This patch works around the issue by avoiding such code generation. See llvm/llvm-project#62235
1 parent da955e0 commit 4862129

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

stdlib/public/core/ValidUTF8Buffer.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ extension _ValidUTF8Buffer: RandomAccessCollection {
127127
@inlinable
128128
@inline(__always)
129129
public func distance(from i: Index, to j: Index) -> Int {
130-
_debugPrecondition(_isValid(i))
130+
// FIXME(katei): The precondition check is commented out because it
131+
// causes bad codegen for `stacksave` on WebAssembly.
132+
// See https://github.com/llvm/llvm-project/issues/62235
133+
// _debugPrecondition(_isValid(i))
131134
_debugPrecondition(_isValid(j))
132135
return (
133136
i._biasedBits.leadingZeroBitCount - j._biasedBits.leadingZeroBitCount

0 commit comments

Comments
 (0)