[PATCH] D53396: [WebAssembly] Fixup main signature by default

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 18 06:39:20 PDT 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.

Repository:
  rL LLVM

https://reviews.llvm.org/D53396

Files:
  lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
  test/CodeGen/WebAssembly/call.ll
  test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
  test/CodeGen/WebAssembly/function-bitcasts.ll
  test/CodeGen/WebAssembly/main-declaration.ll
  test/CodeGen/WebAssembly/main-no-args.ll
  test/CodeGen/WebAssembly/main-with-args.ll


Index: test/CodeGen/WebAssembly/main-with-args.ll
===================================================================
--- test/CodeGen/WebAssembly/main-with-args.ll
+++ test/CodeGen/WebAssembly/main-with-args.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -wasm-temporary-workarounds=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
 
 ; Test that main function with expected signature is not wrapped
 
Index: test/CodeGen/WebAssembly/main-no-args.ll
===================================================================
--- test/CodeGen/WebAssembly/main-no-args.ll
+++ test/CodeGen/WebAssembly/main-no-args.ll
@@ -1,4 +1,5 @@
-; RUN: llc < %s -asm-verbose=false -wasm-temporary-workarounds=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -wasm-fix-main-signature=false | FileCheck %s -check-prefix=NOFIX
 
 ; Test main functions with alternate signatures.
 
@@ -16,3 +17,9 @@
 ; CHECK-NEXT: .param i32, i32
 ; CHECK-NEXT: .result i32
 ; CHECK:      call .L__original_main at FUNCTION
+
+
+; NOFIX-LABEL: main:
+; NOFIX-NEXT: end_function
+
+; NOFIX-NOT: original_main
Index: test/CodeGen/WebAssembly/main-declaration.ll
===================================================================
--- test/CodeGen/WebAssembly/main-declaration.ll
+++ test/CodeGen/WebAssembly/main-declaration.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -wasm-temporary-workarounds=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false | FileCheck %s
 
 ; Test main functions with alternate signatures.
 
Index: test/CodeGen/WebAssembly/function-bitcasts.ll
===================================================================
--- test/CodeGen/WebAssembly/function-bitcasts.ll
+++ test/CodeGen/WebAssembly/function-bitcasts.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions -wasm-temporary-workarounds=false | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -wasm-disable-explicit-locals -wasm-keep-registers -enable-emscripten-cxx-exceptions | FileCheck %s
 
 ; Test that function pointer casts are replaced with wrappers.
 
Index: test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
===================================================================
--- test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
+++ test/CodeGen/WebAssembly/function-bitcasts-varargs.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -wasm-temporary-workarounds=false -wasm-keep-registers | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
 
 ; Test that function pointer casts casting away varargs are replaced with
 ; wrappers.
Index: test/CodeGen/WebAssembly/call.ll
===================================================================
--- test/CodeGen/WebAssembly/call.ll
+++ test/CodeGen/WebAssembly/call.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-temporary-workarounds=false -mattr=+sign-ext,+simd128 | FileCheck %s
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel -fast-isel-abort=1 -wasm-temporary-workarounds=false -mattr=+sign-ext,+simd128 | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -mattr=+sign-ext,+simd128 | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel -fast-isel-abort=1 -mattr=+sign-ext,+simd128 | FileCheck %s
 
 ; Test that basic call operations assemble as expected.
 
Index: lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
+++ lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
@@ -37,9 +37,9 @@
 #define DEBUG_TYPE "wasm-fix-function-bitcasts"
 
 static cl::opt<bool>
-    TemporaryWorkarounds("wasm-temporary-workarounds",
-                         cl::desc("Apply certain temporary workarounds"),
-                         cl::init(true), cl::Hidden);
+    FixMainSignature("wasm-fix-main-signature",
+                     cl::desc("Ensure consisten signature of main function"),
+                     cl::init(true), cl::Hidden);
 
 namespace {
 class FixFunctionBitcasts final : public ModulePass {
@@ -241,7 +241,7 @@
     // "int main(int argc, char *argv[])", create an artificial call with it
     // bitcasted to that type so that we generate a wrapper for it, so that
     // the C runtime can call it.
-    if (!TemporaryWorkarounds && !F.isDeclaration() && F.getName() == "main") {
+    if (FixMainSignature && !F.isDeclaration() && F.getName() == "main") {
       Main = &F;
       LLVMContext &C = M.getContext();
       Type *MainArgTys[] = {Type::getInt32Ty(C),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53396.170077.patch
Type: text/x-patch
Size: 4904 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181018/a71fd3f8/attachment.bin>


More information about the llvm-commits mailing list