diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -961,7 +961,7 @@ continue; const Value *Callee = CI->getCalledValue(); - if (!canLongjmp(M, Callee)) + if (!canLongjmp(M, Callee) || isa(Callee)) continue; Value *Threw = nullptr; diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll --- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll +++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll @@ -188,6 +188,27 @@ ; CHECK-NEXT: call void @emscripten_longjmp_jmpbuf(%struct.__jmp_buf_tag* %[[ARRAYDECAY]], i32 5) #1 } +; Test inline asm handling +define hidden void @inline_asm() #0 { +; CHECK-LABEL: @inline_asm +entry: + %env = alloca [1 x %struct.__jmp_buf_tag], align 16 + %arraydecay = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %env, i32 0, i32 0 + %call = call i32 @setjmp(%struct.__jmp_buf_tag* %arraydecay) #4 + %cmp = icmp eq i32 %call, 0 + br i1 %cmp, label %if.then, label %if.else + +if.then: ; preds = %entry +; CHECK: call void asm sideeffect "", ""() + call void asm sideeffect "", ""() + %arraydecay1 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %env, i32 0, i32 0 + call void @longjmp(%struct.__jmp_buf_tag* %arraydecay1, i32 1) #5 + unreachable + +if.else: ; preds = %entry + ret void +} + declare void @foo() ; Function Attrs: returns_twice declare i32 @setjmp(%struct.__jmp_buf_tag*) #0