[PATCH] D65246: [WebAssembly] Do not emit tail calls with return type mismatch

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 15:14:12 PDT 2019


aheejin added inline comments.


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:649
+    bool MustTail = CLI.CS && CLI.CS.isMustTailCall();
+    if (Subtarget->hasTailCall() && !CLI.IsVarArg) {
+      // Do not tail call unless caller and callee return types match
----------------
Would we need a test case for vararg too?


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:677
+    }
   }
 
----------------
Should we document about these restrictions (such as no vararg) [[ https://llvm.org/docs/CodeGenerator.html#tail-call-optimization | here ]] too, like other platforms?


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp:238
+            valTypesFromMVTs(CallerRetTys, Returns);
+          }
+
----------------
Why should we do this? Is the return type of the tail-called function different from that of the caller? If so, wouldn't we have already disabled tail calling in ISelLowering as you did above?


================
Comment at: llvm/test/CodeGen/WebAssembly/tailcall.ll:215
+; Check that the signatures generated for external indirectly
+; return-called functions include the proper return types
+
----------------
I'm not sure what this test is trying to test..?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65246





More information about the llvm-commits mailing list