Skip to content

Commit f0f30e7

Browse files
kateinoigakukunMaxDesiatov
authored andcommitted
Avoid to emit inline asm for WebAssembly (#5)
When I build swift code as debuggable, I got the following error: ``` error: couldn't allocate input reg for constraint 'r' ``` This means we can't use `InlineAsm` with registers because WASM doesn't have registers. Swift uses `InlineAsm` to extend lifetime of variable for debugging. So I changed to avoid to use it. After this change, we can build swift standard library as debuggable via `./utils/build-script --debug`. ## References - https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html#Simple-Constraints
1 parent 779841b commit f0f30e7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ class IRGenSILFunction :
656656
bool emitLifetimeExtendingUse(llvm::Value *Var) {
657657
llvm::Type *ArgTys;
658658
auto *Ty = Var->getType();
659+
// Avoid to emit when Wasm because of lack of register.
660+
if (IGM.TargetInfo.OutputObjectFormat == llvm::Triple::Wasm) {
661+
return false;
662+
}
659663
// Vectors, Pointers and Floats are expected to fit into a register.
660664
if (Ty->isPointerTy() || Ty->isFloatingPointTy() || Ty->isVectorTy())
661665
ArgTys = {Ty};

0 commit comments

Comments
 (0)