[WebAssembly] Be consistent in generating trivial test input files

For each checked-in wasm file, make sure the there is
corresponding .ll file that can be used to regenerate it
if needed.

Add test/Object/Inputs/trivial-object-test.wasm to match other
formats and add some new wasm tests in test/Object.

Differential Revision: https://reviews.llvm.org/D35213

llvm-svn: 307585
diff --git a/llvm/test/tools/llvm-readobj/Inputs/trivial.ll b/llvm/test/tools/llvm-readobj/Inputs/trivial.ll
index f79b8b8..e0e519d 100644
--- a/llvm/test/tools/llvm-readobj/Inputs/trivial.ll
+++ b/llvm/test/tools/llvm-readobj/Inputs/trivial.ll
@@ -1,9 +1,11 @@
-; llc -mtriple=i386-pc-win32 trivial.ll -filetype=obj -o trivial-object-test.coff-i386
-; llc -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj -o trivial-object-test.coff-x86-64
-; llc -mtriple=i386-linux-gnu trivial.ll -filetype=obj -o trivial-object-test.elf-i386 -relocation-model=pic
-; llc -mtriple=x86_64-linux-gnu trivial.ll -filetype=obj -o trivial-object-test.elf-x86-64 -relocation-model=pic
-; llc -mtriple=i386-apple-darwin10 trivial.ll -filetype=obj -o trivial-object-test.macho-i386 -relocation-model=pic
-; llc -mtriple=x86_64-apple-darwin10 trivial.ll -filetype=obj -o trivial-object-test.macho-x86-64 -relocation-model=pic
+; Input used for generating checked-in binaries (trivial.obj.*)
+; llc -mtriple=i386-pc-win32 trivial.ll -filetype=obj -o trivial.obj.coff-i386
+; llc -mtriple=x86_64-pc-win32 trivial.ll -filetype=obj -o trivial.obj.coff-x86-64
+; llc -mtriple=i386-linux-gnu trivial.ll -filetype=obj -o trivial.obj.elf-i386 -relocation-model=pic
+; llc -mtriple=x86_64-linux-gnu trivial.ll -filetype=obj -o trivial.obj.elf-x86-64 -relocation-model=pic
+; llc -mtriple=i386-apple-darwin10 trivial.ll -filetype=obj -o trivial.obj.macho-i386 -relocation-model=pic
+; llc -mtriple=x86_64-apple-darwin10 trivial.ll -filetype=obj -o trivial.obj.macho-x86-64 -relocation-model=pic
+; llc -mtriple=wasm32-unknown-unknown-wasm trivial.ll -filetype=obj -o trivial.obj.wasm
 
 @.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1
 
diff --git a/llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm b/llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm
index f14192f..caa702f 100644
--- a/llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm
+++ b/llvm/test/tools/llvm-readobj/Inputs/trivial.obj.wasm
Binary files differ
diff --git a/llvm/test/tools/llvm-readobj/file-headers.test b/llvm/test/tools/llvm-readobj/file-headers.test
index 6bc9714..65ccd50 100644
--- a/llvm/test/tools/llvm-readobj/file-headers.test
+++ b/llvm/test/tools/llvm-readobj/file-headers.test
@@ -28,9 +28,6 @@
 RUN:   | FileCheck %s -check-prefix COFF-IMPORTLIB
 RUN: llvm-readobj -h %p/Inputs/trivial.obj.elf-lanai \
 RUN:   | FileCheck %s -check-prefix ELF-LANAI
-# trivial.obj.wasm was generated using the following command:
-# echo "extern int bar, baz; int foo() { return bar + baz + (int)&foo; }" | \
-# ./bin/clang -c -o trivial.obj.wasm -target wasm32-unknown-unknown-wasm -x c -
 RUN: llvm-readobj -h %p/Inputs/trivial.obj.wasm \
 RUN:   | FileCheck %s -check-prefix WASM
 
diff --git a/llvm/test/tools/llvm-readobj/relocations.test b/llvm/test/tools/llvm-readobj/relocations.test
index 9c7dcf1..85ccd3c 100644
--- a/llvm/test/tools/llvm-readobj/relocations.test
+++ b/llvm/test/tools/llvm-readobj/relocations.test
@@ -289,21 +289,20 @@
 WASM:      Relocations [
 WASM-NEXT:   Section (8) CODE {
 WASM-NEXT:     Relocation {
-WASM-NEXT:       Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
-WASM-NEXT:       Offset: 0x6
-WASM-NEXT:       Index: 0x0
-WASM-NEXT:     }
-WASM-NEXT:     Relocation {
-WASM-NEXT:       Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3)
-WASM-NEXT:       Offset: 0x15
+WASM-NEXT:       Type: R_WEBASSEMBLY_GLOBAL_ADDR_SLEB (4)
+WASM-NEXT:       Offset: 0x4
 WASM-NEXT:       Index: 0x0
 WASM-NEXT:       Addend: 0
 WASM-NEXT:     }
 WASM-NEXT:     Relocation {
-WASM-NEXT:       Type: R_WEBASSEMBLY_GLOBAL_ADDR_LEB (3)
-WASM-NEXT:       Offset: 0x24
+WASM-NEXT:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
+WASM-NEXT:       Offset: 0xA
+WASM-NEXT:       Index: 0x0
+WASM-NEXT:     }
+WASM-NEXT:     Relocation {
+WASM-NEXT:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
+WASM-NEXT:       Offset: 0x11
 WASM-NEXT:       Index: 0x1
-WASM-NEXT:       Addend: 0
 WASM-NEXT:     }
 WASM-NEXT:   }
 WASM-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/sections.test b/llvm/test/tools/llvm-readobj/sections.test
index 1747ee4..05dd613 100644
--- a/llvm/test/tools/llvm-readobj/sections.test
+++ b/llvm/test/tools/llvm-readobj/sections.test
@@ -493,62 +493,73 @@
 MACHO-ARM-NEXT:  }
 MACHO-ARM-NEXT:]
 
-WASM: Sections [
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: TYPE (0x1)
-WASM-NEXT:    Size: 5
-WASM-NEXT:    Offset: 8
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: IMPORT (0x2)
-WASM-NEXT:    Size: 23
-WASM-NEXT:    Offset: 19
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: FUNCTION (0x3)
-WASM-NEXT:    Size: 2
-WASM-NEXT:    Offset: 48
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: TABLE (0x4)
-WASM-NEXT:    Size: 4
-WASM-NEXT:    Offset: 56
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: MEMORY (0x5)
-WASM-NEXT:    Size: 3
-WASM-NEXT:    Offset: 66
-WASM-NEXT:    Memories [
-WASM-NEXT:      Memory {
-WASM-NEXT:        InitialPages: 0
-WASM-NEXT:      }
-WASM-NEXT:    ]
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: EXPORT (0x7)
-WASM-NEXT:    Size: 7
-WASM-NEXT:    Offset: 75
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: ELEM (0x9)
-WASM-NEXT:    Size: 7
-WASM-NEXT:    Offset: 88
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: CODE (0xA)
-WASM-NEXT:    Size: 61
-WASM-NEXT:    Offset: 101
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: CUSTOM (0x0)
-WASM-NEXT:    Size: 17
-WASM-NEXT:    Offset: 168
-WASM-NEXT:    Name: name
-WASM-NEXT:  }
-WASM-NEXT:  Section {
-WASM-NEXT:    Type: CUSTOM (0x0)
-WASM-NEXT:    Size: 24
-WASM-NEXT:    Offset: 191
-WASM-NEXT:    Name: reloc.CODE
-WASM-NEXT:  }
-WASM-NEXT:]
+WASM:      Sections [
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: TYPE (0x1)
+WASM-NEXT:     Size: 14
+WASM-NEXT:     Offset: 8
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: IMPORT (0x2)
+WASM-NEXT:     Size: 36
+WASM-NEXT:     Offset: 28
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: FUNCTION (0x3)
+WASM-NEXT:     Size: 2
+WASM-NEXT:     Offset: 70
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: TABLE (0x4)
+WASM-NEXT:     Size: 4
+WASM-NEXT:     Offset: 78
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: MEMORY (0x5)
+WASM-NEXT:     Size: 3
+WASM-NEXT:     Offset: 88
+WASM-NEXT:     Memories [
+WASM-NEXT:       Memory {
+WASM-NEXT:         InitialPages: 1
+WASM-NEXT:       }
+WASM-NEXT:     ]
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: GLOBAL (0x6)
+WASM-NEXT:     Size: 6
+WASM-NEXT:     Offset: 97
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: EXPORT (0x7)
+WASM-NEXT:     Size: 8
+WASM-NEXT:     Offset: 109
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: CODE (0xA)
+WASM-NEXT:     Size: 25
+WASM-NEXT:     Offset: 123
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: DATA (0xB)
+WASM-NEXT:     Size: 19
+WASM-NEXT:     Offset: 154
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: CUSTOM (0x0)
+WASM-NEXT:     Size: 43
+WASM-NEXT:     Offset: 179
+WASM-NEXT:     Name: name
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: CUSTOM (0x0)
+WASM-NEXT:     Size: 23
+WASM-NEXT:     Offset: 228
+WASM-NEXT:     Name: reloc.CODE
+WASM-NEXT:   }
+WASM-NEXT:   Section {
+WASM-NEXT:     Type: CUSTOM (0x0)
+WASM-NEXT:     Size: 22
+WASM-NEXT:     Offset: 257
+WASM-NEXT:     Name: linking
+WASM-NEXT:   }
+WASM-NEXT: ]
diff --git a/llvm/test/tools/llvm-readobj/symbols.test b/llvm/test/tools/llvm-readobj/symbols.test
index da8a70b..380c6f6 100644
--- a/llvm/test/tools/llvm-readobj/symbols.test
+++ b/llvm/test/tools/llvm-readobj/symbols.test
@@ -73,22 +73,32 @@
 
 WASM:      Symbols [
 WASM-NEXT:   Symbol {
-WASM-NEXT:     Name: bar
-WASM-NEXT:     Type: GLOBAL_IMPORT (0x2)
+WASM-NEXT:     Name: puts
+WASM-NEXT:     Type: FUNCTION_IMPORT (0x0)
 WASM-NEXT:     Flags: 0x0
 WASM-NEXT:   }
 WASM-NEXT:   Symbol {
-WASM-NEXT:     Name: baz
-WASM-NEXT:     Type: GLOBAL_IMPORT (0x2)
+WASM-NEXT:     Name: SomeOtherFunction
+WASM-NEXT:     Type: FUNCTION_IMPORT (0x0)
 WASM-NEXT:     Flags: 0x0
 WASM-NEXT:   }
 WASM-NEXT:   Symbol {
-WASM-NEXT:     Name: foo
+WASM-NEXT:     Name: main
 WASM-NEXT:     Type: FUNCTION_EXPORT (0x1)
 WASM-NEXT:     Flags: 0x0
 WASM-NEXT:   }
 WASM-NEXT:   Symbol {
-WASM-NEXT:     Name: foo
+WASM-NEXT:     Name: puts
+WASM-NEXT:     Type: DEBUG_FUNCTION_NAME (0x4)
+WASM-NEXT:     Flags: 0x0
+WASM-NEXT:   }
+WASM-NEXT:   Symbol {
+WASM-NEXT:     Name: SomeOtherFunction
+WASM-NEXT:     Type: DEBUG_FUNCTION_NAME (0x4)
+WASM-NEXT:     Flags: 0x0
+WASM-NEXT:   }
+WASM-NEXT:   Symbol {
+WASM-NEXT:     Name: main
 WASM-NEXT:     Type: DEBUG_FUNCTION_NAME (0x4)
 WASM-NEXT:     Flags: 0x0
 WASM-NEXT:   }