[PATCH] D106524: [WebAssembly] Improve pseudocode in LowerEmscriptenEHSjLj

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 10:13:55 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b9aba43a239: [WebAssembly] Improve pseudocode in LowerEmscriptenEHSjLj (authored by aheejin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106524/new/

https://reviews.llvm.org/D106524

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp


Index: llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -49,6 +49,8 @@
 ///    means nothing occurred, 1 means an exception occurred, and other numbers
 ///    mean a longjmp occurred. In the case of longjmp, __THREW__ variable
 ///    indicates the corresponding setjmp buffer the longjmp corresponds to.
+///    __threwValue is 0 for exceptions, and the argument to longjmp in case of
+///    longjmp.
 ///
 /// * Exception handling
 ///
@@ -158,12 +160,13 @@
 ///      call @__invoke_SIG(func, arg1, arg2)
 ///      %__THREW__.val = __THREW__;
 ///      __THREW__ = 0;
-///      if (%__THREW__.val != 0 & __threwValue != 0) {
+///      %__threwValue.val = __threwValue;
+///      if (%__THREW__.val != 0 & %__threwValue.val != 0) {
 ///        %label = testSetjmp(mem[%__THREW__.val], setjmpTable,
 ///                            setjmpTableSize);
 ///        if (%label == 0)
-///          emscripten_longjmp(%__THREW__.val, __threwValue);
-///        setTempRet0(__threwValue);
+///          emscripten_longjmp(%__THREW__.val, %__threwValue.val);
+///        setTempRet0(%__threwValue.val);
 ///      } else {
 ///        %label = -1;
 ///      }
@@ -177,7 +180,7 @@
 ///    testSetjmp examines setjmpTable to see if there is a matching setjmp
 ///    call. After calling an invoke wrapper, if a longjmp occurred, __THREW__
 ///    will be the address of matching jmp_buf buffer and __threwValue be the
-///    second argument to longjmp. mem[__THREW__.val] is a setjmp ID that is
+///    second argument to longjmp. mem[%__THREW__.val] is a setjmp ID that is
 ///    stored in saveSetjmp. testSetjmp returns a setjmp label, a unique ID to
 ///    each setjmp callsite. Label 0 means this longjmp buffer does not
 ///    correspond to one of the setjmp callsites in this function, so in this
@@ -546,11 +549,12 @@
 
 // Generate testSetjmp function call seqence with preamble and postamble.
 // The code this generates is equivalent to the following JavaScript code:
-// if (%__THREW__.val != 0 & threwValue != 0) {
+// %__threwValue.val = __threwValue;
+// if (%__THREW__.val != 0 & %__threwValue.val != 0) {
 //   %label = _testSetjmp(mem[%__THREW__.val], setjmpTable, setjmpTableSize);
 //   if (%label == 0)
-//     emscripten_longjmp(%__THREW__.val, threwValue);
-//   setTempRet0(threwValue);
+//     emscripten_longjmp(%__THREW__.val, %__threwValue.val);
+//   setTempRet0(%__threwValue.val);
 // } else {
 //   %label = -1;
 // }
@@ -568,7 +572,7 @@
   IRBuilder<> IRB(C);
   IRB.SetCurrentDebugLocation(DL);
 
-  // if (%__THREW__.val != 0 & threwValue != 0)
+  // if (%__THREW__.val != 0 & %__threwValue.val != 0)
   IRB.SetInsertPoint(BB);
   BasicBlock *ThenBB1 = BasicBlock::Create(C, "if.then1", F);
   BasicBlock *ElseBB1 = BasicBlock::Create(C, "if.else1", F);
@@ -594,12 +598,12 @@
   Value *Cmp2 = IRB.CreateICmpEQ(ThenLabel, IRB.getInt32(0));
   IRB.CreateCondBr(Cmp2, ThenBB2, EndBB2);
 
-  // emscripten_longjmp(%__THREW__.val, threwValue);
+  // emscripten_longjmp(%__THREW__.val, %__threwValue.val);
   IRB.SetInsertPoint(ThenBB2);
   IRB.CreateCall(EmLongjmpF, {Threw, ThrewValue});
   IRB.CreateUnreachable();
 
-  // setTempRet0(threwValue);
+  // setTempRet0(%__threwValue.val);
   IRB.SetInsertPoint(EndBB2);
   IRB.CreateCall(SetTempRet0Func, ThrewValue);
   IRB.CreateBr(EndBB1);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106524.361712.patch
Type: text/x-patch
Size: 3540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210726/c0596f2b/attachment.bin>


More information about the llvm-commits mailing list