Skip to content

Commit 8f54fe5

Browse files
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 60c7e50 commit 8f54fe5

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
@@ -666,6 +666,10 @@ class IRGenSILFunction :
666666
bool emitLifetimeExtendingUse(llvm::Value *Var) {
667667
llvm::Type *ArgTys;
668668
auto *Ty = Var->getType();
669+
// Avoid to emit when Wasm because of lack of register.
670+
if (IGM.TargetInfo.OutputObjectFormat == llvm::Triple::Wasm) {
671+
return false;
672+
}
669673
// Vectors, Pointers and Floats are expected to fit into a register.
670674
if (Ty->isPointerTy() || Ty->isFloatingPointTy() || Ty->isVectorTy())
671675
ArgTys = {Ty};

0 commit comments

Comments
 (0)