[llvm] r326334 - [WebAssembly] Reorder symbol table to match MC order

Nicholas Wilson via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 09:19:49 PST 2018


Author: ncw
Date: Wed Feb 28 09:19:48 2018
New Revision: 326334

URL: http://llvm.org/viewvc/llvm-project?rev=326334&view=rev
Log:
[WebAssembly] Reorder symbol table to match MC order

This removes a TODO introduced in rL325860

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

Modified:
    llvm/trunk/lib/MC/WasmObjectWriter.cpp
    llvm/trunk/test/MC/WebAssembly/comdat.ll
    llvm/trunk/test/MC/WebAssembly/external-data.ll
    llvm/trunk/test/MC/WebAssembly/external-func-address.ll
    llvm/trunk/test/MC/WebAssembly/func-address.ll
    llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll
    llvm/trunk/test/MC/WebAssembly/reloc-code.ll
    llvm/trunk/test/MC/WebAssembly/reloc-data.ll
    llvm/trunk/test/MC/WebAssembly/weak-alias.ll
    llvm/trunk/test/MC/WebAssembly/weak.ll

Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Wed Feb 28 09:19:48 2018
@@ -974,32 +974,8 @@ void WasmObjectWriter::writeObject(MCAss
   SmallVector<wasm::WasmSymbolInfo, 4> SymbolInfos;
   SmallVector<std::pair<uint16_t, uint32_t>, 2> InitFuncs;
   std::map<StringRef, std::vector<WasmComdatEntry>> Comdats;
-  unsigned NumSymbols = 0;
   uint32_t DataSize = 0;
 
-  auto AddSymbol = [&](const MCSymbolWasm &WS) {
-    uint32_t Flags = 0;
-    if (WS.isWeak())
-      Flags |= wasm::WASM_SYMBOL_BINDING_WEAK;
-    if (WS.isHidden())
-      Flags |= wasm::WASM_SYMBOL_VISIBILITY_HIDDEN;
-    if (!WS.isExternal() && WS.isDefined())
-      Flags |= wasm::WASM_SYMBOL_BINDING_LOCAL;
-    if (WS.isUndefined())
-      Flags |= wasm::WASM_SYMBOL_UNDEFINED;
-
-    wasm::WasmSymbolInfo Info;
-    Info.Name = WS.getName();
-    Info.Kind = WS.getType();
-    Info.Flags = Flags;
-    if (!WS.isData())
-      Info.ElementIndex = WasmIndices[&WS];
-    else if (WS.isDefined())
-      Info.DataRef = DataLocations[&WS];
-    SymbolInfos.emplace_back(Info);
-    SymbolIndices[&WS] = NumSymbols++;
-  };
-
   // For now, always emit the memory import, since loads and stores are not
   // valid without it. In the future, we could perhaps be more clever and omit
   // it if there are no loads or stores.
@@ -1023,7 +999,9 @@ void WasmObjectWriter::writeObject(MCAss
   TableImport.Table.ElemType = wasm::WASM_TYPE_ANYFUNC;
   Imports.push_back(TableImport);
 
-  // Populate FunctionTypeIndices and Imports.
+  // Populate FunctionTypeIndices, and Imports and WasmIndices for undefined
+  // symbols.  This must be done before populating WasmIndices for defined
+  // symbols.
   for (const MCSymbol &S : Asm.symbols()) {
     const auto &WS = static_cast<const MCSymbolWasm &>(S);
 
@@ -1054,17 +1032,10 @@ void WasmObjectWriter::writeObject(MCAss
         Imports.push_back(Import);
         WasmIndices[&WS] = NumGlobalImports++;
       }
-
-      // TODO(ncw) We shouldn't be adding the symbol to the symbol table here!
-      // Instead it should be done by removing the "if (WS.isDefined())" block
-      // in the big loop below (line ~1284).  However - that would reorder all
-      // the symbols and thus require all the tests to be updated.  I think it's
-      // better to make that change therefore in a future commit, to isolate
-      // each test update from the change that caused it.
-      AddSymbol(WS);
     }
   }
 
+  // Populate DataSegments, which must be done before populating DataLocations.
   for (MCSection &Sec : Asm) {
     auto &Section = static_cast<MCSectionWasm &>(Sec);
     if (!Section.isWasmData())
@@ -1093,7 +1064,7 @@ void WasmObjectWriter::writeObject(MCAss
     }
   }
 
-  // Handle regular defined and undefined symbols.
+  // Populate WasmIndices and DataLocations for defined symbols.
   for (const MCSymbol &S : Asm.symbols()) {
     // Ignore unnamed temporary symbols, which aren't ever exported, imported,
     // or used in relocations.
@@ -1182,14 +1153,12 @@ void WasmObjectWriter::writeObject(MCAss
       DEBUG(dbgs() << "  -> global index: " << WasmIndices.find(&WS)->second
                    << "\n");
     }
-
-    if (WS.isDefined())
-      AddSymbol(WS);
   }
 
-  // Handle weak aliases. We need to process these in a separate pass because
-  // we need to have processed the target of the alias before the alias itself
-  // and the symbols are not necessarily ordered in this way.
+  // Populate WasmIndices and DataLocations for aliased symbols.  We need to
+  // process these in a separate pass because we need to have processed the
+  // target of the alias before the alias itself and the symbols are not
+  // necessarily ordered in this way.
   for (const MCSymbol &S : Asm.symbols()) {
     if (!S.isVariable())
       continue;
@@ -1215,8 +1184,38 @@ void WasmObjectWriter::writeObject(MCAss
     } else {
       report_fatal_error("don't yet support global aliases");
     }
+  }
 
-    AddSymbol(WS);
+  // Finally, populate the symbol table itself, in its "natural" order.
+  for (const MCSymbol &S : Asm.symbols()) {
+    const auto &WS = static_cast<const MCSymbolWasm &>(S);
+    if (WS.isTemporary() && WS.getName().empty())
+      continue;
+    if (WS.isComdat() && !WS.isDefined())
+      continue;
+    if (WS.isTemporary() && WS.isData() && !WS.getSize())
+      continue;
+
+    uint32_t Flags = 0;
+    if (WS.isWeak())
+      Flags |= wasm::WASM_SYMBOL_BINDING_WEAK;
+    if (WS.isHidden())
+      Flags |= wasm::WASM_SYMBOL_VISIBILITY_HIDDEN;
+    if (!WS.isExternal() && WS.isDefined())
+      Flags |= wasm::WASM_SYMBOL_BINDING_LOCAL;
+    if (WS.isUndefined())
+      Flags |= wasm::WASM_SYMBOL_UNDEFINED;
+
+    wasm::WasmSymbolInfo Info;
+    Info.Name = WS.getName();
+    Info.Kind = WS.getType();
+    Info.Flags = Flags;
+    if (!WS.isData())
+      Info.ElementIndex = WasmIndices.find(&WS)->second;
+    else if (WS.isDefined())
+      Info.DataRef = DataLocations.find(&WS)->second;
+    SymbolIndices[&WS] = SymbolInfos.size();
+    SymbolInfos.emplace_back(Info);
   }
 
   {

Modified: llvm/trunk/test/MC/WebAssembly/comdat.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/comdat.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/comdat.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/comdat.ll Wed Feb 28 09:19:48 2018
@@ -53,7 +53,7 @@ define linkonce_odr i32 @sharedFn() #1 c
 ; CHECK-NEXT:  - Type:            CODE
 ; CHECK-NEXT:    Relocations:
 ; CHECK-NEXT:      - Type:            R_WEBASSEMBLY_FUNCTION_INDEX_LEB
-; CHECK-NEXT:        Index:           0
+; CHECK-NEXT:        Index:           1
 ; CHECK-NEXT:        Offset:          0x00000004
 ; CHECK-NEXT:    Functions:
 ; CHECK-NEXT:      - Index:           1
@@ -78,14 +78,14 @@ define linkonce_odr i32 @sharedFn() #1 c
 ; CHECK-NEXT:    SymbolTable:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            FUNCTION
-; CHECK-NEXT:         Name:            funcImport
-; CHECK-NEXT:         Flags:           [ UNDEFINED ]
-; CHECK-NEXT:         Function:        0
-; CHECK-NEXT:       - Index:           1
-; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            callImport
 ; CHECK-NEXT:         Flags:           [  ]
 ; CHECK-NEXT:         Function:        1
+; CHECK-NEXT:       - Index:           1
+; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            funcImport
+; CHECK-NEXT:         Flags:           [ UNDEFINED ]
+; CHECK-NEXT:         Function:        0
 ; CHECK-NEXT:       - Index:           2
 ; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            basicInlineFn

Modified: llvm/trunk/test/MC/WebAssembly/external-data.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/external-data.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/external-data.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/external-data.ll Wed Feb 28 09:19:48 2018
@@ -13,7 +13,7 @@ target triple = "wasm32-unknown-unknown-
 ; CHECK:        - Type:            DATA
 ; CHECK-NEXT:     Relocations:
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_MEMORY_ADDR_I32
-; CHECK-NEXT:         Index:           0
+; CHECK-NEXT:         Index:           2
 ; CHECK-NEXT:         Offset:          0x00000013
 ; CHECK-NEXT:     Segments:
 ; CHECK-NEXT:       - SectionOffset:   6

Modified: llvm/trunk/test/MC/WebAssembly/external-func-address.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/external-func-address.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/external-func-address.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/external-func-address.ll Wed Feb 28 09:19:48 2018
@@ -44,5 +44,5 @@ declare void @f1(i32) #1
 ; CHECK:        - Type:            DATA
 ; CHECK-NEXT:     Relocations:
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_TABLE_INDEX_I32
-; CHECK-NEXT:         Index:           0
+; CHECK-NEXT:         Index:           1
 ; CHECK-NEXT:         Offset:          0x00000006

Modified: llvm/trunk/test/MC/WebAssembly/func-address.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/func-address.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/func-address.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/func-address.ll Wed Feb 28 09:19:48 2018
@@ -34,16 +34,16 @@ entry:
 ; CHECK:     Relocation {
 ; CHECK:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
 ; CHECK:       Offset: 0x4
-; CHECK:       Index: 0x0
+; CHECK:       Index: 0x1
 ; CHECK:     }
 ; CHECK:     Relocation {
 ; CHECK:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
 ; CHECK:       Offset: 0xB
-; CHECK:       Index: 0x1
+; CHECK:       Index: 0x2
 ; CHECK:     }
 ; CHECK:     Relocation {
 ; CHECK:       Type: R_WEBASSEMBLY_TABLE_INDEX_SLEB (1)
 ; CHECK:       Offset: 0x1E
-; CHECK:       Index: 0x3
+; CHECK:       Index: 0x5
 ; CHECK:     }
 ; CHECK:   }

Modified: llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/global-ctor-dtor.ll Wed Feb 28 09:19:48 2018
@@ -64,28 +64,28 @@ declare void @func3()
 ; CHECK-NEXT:   - Type:            CODE
 ; CHECK-NEXT:     Relocations:     
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_FUNCTION_INDEX_LEB
-; CHECK-NEXT:         Index:           0
+; CHECK-NEXT:         Index:           1
 ; CHECK-NEXT:         Offset:          0x00000004
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_TABLE_INDEX_SLEB
-; CHECK-NEXT:         Index:           6
+; CHECK-NEXT:         Index:           0
 ; CHECK-NEXT:         Offset:          0x0000000F
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_MEMORY_ADDR_SLEB
-; CHECK-NEXT:         Index:           1
+; CHECK-NEXT:         Index:           3
 ; CHECK-NEXT:         Offset:          0x00000017
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_FUNCTION_INDEX_LEB
-; CHECK-NEXT:         Index:           2
+; CHECK-NEXT:         Index:           4
 ; CHECK-NEXT:         Offset:          0x0000001D
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_FUNCTION_INDEX_LEB
-; CHECK-NEXT:         Index:           3
+; CHECK-NEXT:         Index:           6
 ; CHECK-NEXT:         Offset:          0x0000002C
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_TABLE_INDEX_SLEB
-; CHECK-NEXT:         Index:           8
+; CHECK-NEXT:         Index:           5
 ; CHECK-NEXT:         Offset:          0x00000037
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_MEMORY_ADDR_SLEB
-; CHECK-NEXT:         Index:           1
+; CHECK-NEXT:         Index:           3
 ; CHECK-NEXT:         Offset:          0x0000003F
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_FUNCTION_INDEX_LEB
-; CHECK-NEXT:         Index:           2
+; CHECK-NEXT:         Index:           4
 ; CHECK-NEXT:         Offset:          0x00000045
 ; CHECK-NEXT:     Functions:       
 ; CHECK-NEXT:       - Index:           5
@@ -113,71 +113,71 @@ declare void @func3()
 ; CHECK-NEXT:     SymbolTable:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            .Lcall_dtors.42
+; CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
+; CHECK-NEXT:         Function:        5
+; CHECK-NEXT:       - Index:           1
+; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            func3
 ; CHECK-NEXT:         Flags:           [ UNDEFINED ]
 ; CHECK-NEXT:         Function:        0
-; CHECK-NEXT:       - Index:           1
+; CHECK-NEXT:       - Index:           2
+; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            .Lregister_call_dtors.42
+; CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
+; CHECK-NEXT:         Function:        6
+; CHECK-NEXT:       - Index:           3
 ; CHECK-NEXT:         Kind:            DATA
 ; CHECK-NEXT:         Name:            __dso_handle
 ; CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN, UNDEFINED ]
-; CHECK-NEXT:       - Index:           2
+; CHECK-NEXT:       - Index:           4
 ; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            __cxa_atexit
 ; CHECK-NEXT:         Flags:           [ UNDEFINED ]
 ; CHECK-NEXT:         Function:        1
-; CHECK-NEXT:       - Index:           3
-; CHECK-NEXT:         Kind:            FUNCTION
-; CHECK-NEXT:         Name:            func2
-; CHECK-NEXT:         Flags:           [ UNDEFINED ]
-; CHECK-NEXT:         Function:        2
-; CHECK-NEXT:       - Index:           4
-; CHECK-NEXT:         Kind:            FUNCTION
-; CHECK-NEXT:         Name:            func1
-; CHECK-NEXT:         Flags:           [ UNDEFINED ]
-; CHECK-NEXT:         Function:        3
 ; CHECK-NEXT:       - Index:           5
 ; CHECK-NEXT:         Kind:            FUNCTION
-; CHECK-NEXT:         Name:            func0
-; CHECK-NEXT:         Flags:           [ UNDEFINED ]
-; CHECK-NEXT:         Function:        4
-; CHECK-NEXT:       - Index:           6
-; CHECK-NEXT:         Kind:            FUNCTION
-; CHECK-NEXT:         Name:            .Lcall_dtors.42
-; CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
-; CHECK-NEXT:         Function:        5
-; CHECK-NEXT:       - Index:           7
-; CHECK-NEXT:         Kind:            FUNCTION
-; CHECK-NEXT:         Name:            .Lregister_call_dtors.42
-; CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
-; CHECK-NEXT:         Function:        6
-; CHECK-NEXT:       - Index:           8
-; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            .Lcall_dtors
 ; CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
 ; CHECK-NEXT:         Function:        7
-; CHECK-NEXT:       - Index:           9
+; CHECK-NEXT:       - Index:           6
+; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            func2
+; CHECK-NEXT:         Flags:           [ UNDEFINED ]
+; CHECK-NEXT:         Function:        2
+; CHECK-NEXT:       - Index:           7
 ; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            .Lregister_call_dtors
 ; CHECK-NEXT:         Flags:           [ BINDING_LOCAL ]
 ; CHECK-NEXT:         Function:        8
-; CHECK-NEXT:       - Index:           10
+; CHECK-NEXT:       - Index:           8
 ; CHECK-NEXT:         Kind:            DATA
 ; CHECK-NEXT:         Name:            global1
 ; CHECK-NEXT:         Flags:           [  ]
 ; CHECK-NEXT:         Segment:         0
 ; CHECK-NEXT:         Size:            4
-; CHECK-NEXT:     SegmentInfo:     
+; CHECK-NEXT:       - Index:           9
+; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            func1
+; CHECK-NEXT:         Flags:           [ UNDEFINED ]
+; CHECK-NEXT:         Function:        3
+; CHECK-NEXT:       - Index:           10
+; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            func0
+; CHECK-NEXT:         Flags:           [ UNDEFINED ]
+; CHECK-NEXT:         Function:        4
+; CHECK-NEXT:     SegmentInfo:
 ; CHECK-NEXT:       - Index:           0
 ; CHECK-NEXT:         Name:            .data.global1
 ; CHECK-NEXT:         Alignment:       8
 ; CHECK-NEXT:         Flags:           [ ]
 ; CHECK-NEXT:     InitFunctions:     
 ; CHECK-NEXT:       - Priority: 42
-; CHECK-NEXT:         Symbol: 4
+; CHECK-NEXT:         Symbol: 9
 ; CHECK-NEXT:       - Priority: 42
-; CHECK-NEXT:         Symbol: 7
+; CHECK-NEXT:         Symbol: 2
 ; CHECK-NEXT:       - Priority: 65535
-; CHECK-NEXT:         Symbol: 5
+; CHECK-NEXT:         Symbol: 10
 ; CHECK-NEXT:       - Priority: 65535
-; CHECK-NEXT:         Symbol: 9
+; CHECK-NEXT:         Symbol: 7
 ; CHECK-NEXT: ...

Modified: llvm/trunk/test/MC/WebAssembly/reloc-code.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/reloc-code.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/reloc-code.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/reloc-code.ll Wed Feb 28 09:19:48 2018
@@ -28,13 +28,13 @@ entry:
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
 ; CHECK-NEXT:       Offset: 0x9
-; CHECK-NEXT:       Index: 0x3
+; CHECK-NEXT:       Index: 0x1
 ; CHECK-NEXT:       Addend: 0
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB (3)
 ; CHECK-NEXT:       Offset: 0x14
-; CHECK-NEXT:       Index: 0x4
+; CHECK-NEXT:       Index: 0x2
 ; CHECK-NEXT:       Addend: 0
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:     Relocation {
@@ -50,12 +50,12 @@ entry:
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
 ; CHECK-NEXT:       Offset: 0x2D
-; CHECK-NEXT:       Index: 0x0
+; CHECK-NEXT:       Index: 0x3
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB (0)
 ; CHECK-NEXT:       Offset: 0x34
-; CHECK-NEXT:       Index: 0x1
+; CHECK-NEXT:       Index: 0x4
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:   }
 ; CHECK-NEXT: ]

Modified: llvm/trunk/test/MC/WebAssembly/reloc-data.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/reloc-data.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/reloc-data.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/reloc-data.ll Wed Feb 28 09:19:48 2018
@@ -17,31 +17,31 @@ target triple = "wasm32-unknown-unknown-
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
 ; CHECK-NEXT:       Offset: 0x13
-; CHECK-NEXT:       Index: 0x0
+; CHECK-NEXT:       Index: 0x2
 ; CHECK-NEXT:       Addend: 8
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
 ; CHECK-NEXT:       Offset: 0x1C
-; CHECK-NEXT:       Index: 0x1
+; CHECK-NEXT:       Index: 0x0
 ; CHECK-NEXT:       Addend: -16
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
 ; CHECK-NEXT:       Offset: 0x25
-; CHECK-NEXT:       Index: 0x0
+; CHECK-NEXT:       Index: 0x2
 ; CHECK-NEXT:       Addend: 0
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
 ; CHECK-NEXT:       Offset: 0x29
-; CHECK-NEXT:       Index: 0x0
+; CHECK-NEXT:       Index: 0x2
 ; CHECK-NEXT:       Addend: 0
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:     Relocation {
 ; CHECK-NEXT:       Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 (5)
 ; CHECK-NEXT:       Offset: 0x2D
-; CHECK-NEXT:       Index: 0x0
+; CHECK-NEXT:       Index: 0x2
 ; CHECK-NEXT:       Addend: 0
 ; CHECK-NEXT:     }
 ; CHECK-NEXT:   }

Modified: llvm/trunk/test/MC/WebAssembly/weak-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/weak-alias.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/weak-alias.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/weak-alias.ll Wed Feb 28 09:19:48 2018
@@ -79,16 +79,16 @@ entry:
 ; CHECK-NEXT:         Index:           0
 ; CHECK-NEXT:         Offset:          0x00000009
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_FUNCTION_INDEX_LEB
-; CHECK-NEXT:         Index:           8
+; CHECK-NEXT:         Index:           3
 ; CHECK-NEXT:         Offset:          0x00000012
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_MEMORY_ADDR_LEB
-; CHECK-NEXT:         Index:           4
+; CHECK-NEXT:         Index:           5
 ; CHECK-NEXT:         Offset:          0x0000001E
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_TYPE_INDEX_LEB
 ; CHECK-NEXT:         Index:           0
 ; CHECK-NEXT:         Offset:          0x00000024
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_MEMORY_ADDR_LEB
-; CHECK-NEXT:         Index:           6
+; CHECK-NEXT:         Index:           7
 ; CHECK-NEXT:         Offset:          0x00000031
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_TYPE_INDEX_LEB
 ; CHECK-NEXT:         Index:           0
@@ -115,7 +115,7 @@ entry:
 ; CHECK-NEXT:         Index:           0
 ; CHECK-NEXT:         Offset:          0x0000000F
 ; CHECK-NEXT:       - Type:            R_WEBASSEMBLY_TABLE_INDEX_I32
-; CHECK-NEXT:         Index:           8
+; CHECK-NEXT:         Index:           3
 ; CHECK-NEXT:         Offset:          0x00000018
 ; CHECK-NEXT:     Segments:        
 ; CHECK-NEXT:       - SectionOffset:   6
@@ -156,37 +156,37 @@ entry:
 ; CHECK-NEXT:         Function:        2
 ; CHECK-NEXT:       - Index:           3
 ; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            foo_alias
+; CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN ]
+; CHECK-NEXT:         Function:        0
+; CHECK-NEXT:       - Index:           4
+; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            call_direct_ptr
 ; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
 ; CHECK-NEXT:         Function:        3
-; CHECK-NEXT:       - Index:           4
+; CHECK-NEXT:       - Index:           5
 ; CHECK-NEXT:         Kind:            DATA
 ; CHECK-NEXT:         Name:            direct_address
 ; CHECK-NEXT:         Flags:           [  ]
 ; CHECK-NEXT:         Segment:         1
 ; CHECK-NEXT:         Size:            4
-; CHECK-NEXT:       - Index:           5
+; CHECK-NEXT:       - Index:           6
 ; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            call_alias_ptr
 ; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
 ; CHECK-NEXT:         Function:        4
-; CHECK-NEXT:       - Index:           6
+; CHECK-NEXT:       - Index:           7
 ; CHECK-NEXT:         Kind:            DATA
 ; CHECK-NEXT:         Name:            alias_address
 ; CHECK-NEXT:         Flags:           [  ]
 ; CHECK-NEXT:         Segment:         2
 ; CHECK-NEXT:         Size:            4
-; CHECK-NEXT:       - Index:           7
+; CHECK-NEXT:       - Index:           8
 ; CHECK-NEXT:         Kind:            DATA
 ; CHECK-NEXT:         Name:            bar
 ; CHECK-NEXT:         Flags:           [  ]
 ; CHECK-NEXT:         Segment:         0
 ; CHECK-NEXT:         Size:            4
-; CHECK-NEXT:       - Index:           8
-; CHECK-NEXT:         Kind:            FUNCTION
-; CHECK-NEXT:         Name:            foo_alias
-; CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN ]
-; CHECK-NEXT:         Function:        0
 ; CHECK-NEXT:       - Index:           9
 ; CHECK-NEXT:         Kind:            DATA
 ; CHECK-NEXT:         Name:            bar_alias
@@ -212,10 +212,10 @@ entry:
 ; CHECK-SYMS-NEXT: 00000000 g     F CODE	.hidden foo
 ; CHECK-SYMS-NEXT: 00000001 g     F CODE	.hidden call_direct
 ; CHECK-SYMS-NEXT: 00000002 g     F CODE	.hidden call_alias
+; CHECK-SYMS-NEXT: 00000000 gw    F CODE	.hidden foo_alias
 ; CHECK-SYMS-NEXT: 00000003 g     F CODE	.hidden call_direct_ptr
 ; CHECK-SYMS-NEXT: 00000008 g       DATA	direct_address
 ; CHECK-SYMS-NEXT: 00000004 g     F CODE	.hidden call_alias_ptr
 ; CHECK-SYMS-NEXT: 00000010 g       DATA	alias_address
 ; CHECK-SYMS-NEXT: 00000000 g       DATA	bar
-; CHECK-SYMS-NEXT: 00000000 gw    F CODE	.hidden foo_alias
 ; CHECK-SYMS-NEXT: 00000000 gw      DATA	.hidden bar_alias

Modified: llvm/trunk/test/MC/WebAssembly/weak.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/weak.ll?rev=326334&r1=326333&r2=326334&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/weak.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/weak.ll Wed Feb 28 09:19:48 2018
@@ -24,12 +24,12 @@ entry:
 ; CHECK-NEXT:     Name:            linking
 ; CHECK-NEXT:     SymbolTable:      
 ; CHECK-NEXT:       - Index:           0
-; CHECK-NEXT:         Kind:            DATA
-; CHECK-NEXT:         Name:            weak_external_data
-; CHECK-NEXT:         Flags:           [ BINDING_WEAK, UNDEFINED ]
-; CHECK-NEXT:       - Index:           1
 ; CHECK-NEXT:         Kind:            FUNCTION
 ; CHECK-NEXT:         Name:            weak_function
 ; CHECK-NEXT:         Flags:           [ BINDING_WEAK, VISIBILITY_HIDDEN ]
 ; CHECK-NEXT:         Function:        0
+; CHECK-NEXT:       - Index:           1
+; CHECK-NEXT:         Kind:            DATA
+; CHECK-NEXT:         Name:            weak_external_data
+; CHECK-NEXT:         Flags:           [ BINDING_WEAK, UNDEFINED ]
 ; CHECK-NEXT: ...




More information about the llvm-commits mailing list