[lld] r321244 - [WebAssmebly] Fix references to weak aliases

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 18:43:39 PST 2017


Author: sbc
Date: Wed Dec 20 18:43:39 2017
New Revision: 321244

URL: http://llvm.org/viewvc/llvm-project?rev=321244&view=rev
Log:
[WebAssmebly] Fix references to weak aliases

Corresponding LLVM change: https://reviews.llvm.org/D41472

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

Modified:
    lld/trunk/test/wasm/weak-alias-overide.ll
    lld/trunk/wasm/InputFiles.cpp
    lld/trunk/wasm/SymbolTable.cpp

Modified: lld/trunk/test/wasm/weak-alias-overide.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/weak-alias-overide.ll?rev=321244&r1=321243&r2=321244&view=diff
==============================================================================
--- lld/trunk/test/wasm/weak-alias-overide.ll (original)
+++ lld/trunk/test/wasm/weak-alias-overide.ll Wed Dec 20 18:43:39 2017
@@ -79,7 +79,7 @@ entry:
 ; CHECK-NEXT:       - Offset:          
 ; CHECK-NEXT:           Opcode:          I32_CONST
 ; CHECK-NEXT:           Value:           1
-; CHECK-NEXT:         Functions:       [ 0 ]
+; CHECK-NEXT:         Functions:       [ 2 ]
 ; CHECK-NEXT:   - Type:            CODE
 ; CHECK-NEXT:     Functions:
 ; CHECK-NEXT:       - Locals:
@@ -89,7 +89,7 @@ entry:
 ; CHECK-NEXT:       - Locals:
 ; CHECK-NEXT:         Body:            41000B
 ; CHECK-NEXT:       - Locals:
-; CHECK-NEXT:         Body:            1080808080000B
+; CHECK-NEXT:         Body:            1082808080000B
 ; CHECK-NEXT:       - Locals:
 ; CHECK-NEXT:         Body:            1080808080000B
 ; CHECK-NEXT:       - Locals:          
@@ -97,7 +97,7 @@ entry:
 ; CHECK-NEXT:       - Locals:          
 ; CHECK-NEXT:           - Type:            I32
 ; CHECK-NEXT:             Count:           2
-; CHECK-NEXT:         Body:            23808080800041106B220024808080800020004181808080003602081080808080002101200041106A24808080800020010B
+; CHECK-NEXT:         Body:            23808080800041106B220024808080800020004181808080003602081082808080002101200041106A24808080800020010B
 ; CHECK-NEXT:   - Type:            CUSTOM
 ; CHECK-NEXT:     Name:            linking
 ; CHECK-NEXT:     DataSize:        0

Modified: lld/trunk/wasm/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/InputFiles.cpp?rev=321244&r1=321243&r2=321244&view=diff
==============================================================================
--- lld/trunk/wasm/InputFiles.cpp (original)
+++ lld/trunk/wasm/InputFiles.cpp Wed Dec 20 18:43:39 2017
@@ -198,13 +198,22 @@ void ObjFile::initializeSymbols() {
       DEBUG(dbgs() << "Function: " << WasmSym.ElementIndex << " -> "
                    << toString(*S) << "\n");
       FunctionSymbols[WasmSym.ElementIndex] = S;
+      if (WasmSym.HasAltIndex)
+        FunctionSymbols[WasmSym.AltIndex] = S;
     } else {
       DEBUG(dbgs() << "Global: " << WasmSym.ElementIndex << " -> "
                    << toString(*S) << "\n");
       GlobalSymbols[WasmSym.ElementIndex] = S;
+      if (WasmSym.HasAltIndex)
+        GlobalSymbols[WasmSym.AltIndex] = S;
     }
   }
 
+  DEBUG(for (size_t I = 0; I < FunctionSymbols.size(); ++I)
+            assert(FunctionSymbols[I] != nullptr);
+        for (size_t I = 0; I < GlobalSymbols.size(); ++I)
+            assert(GlobalSymbols[I] != nullptr););
+
   // Populate `TableSymbols` with all symbols that are called indirectly
   uint32_t SegmentCount = WasmObj->elements().size();
   if (SegmentCount) {

Modified: lld/trunk/wasm/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/SymbolTable.cpp?rev=321244&r1=321243&r2=321244&view=diff
==============================================================================
--- lld/trunk/wasm/SymbolTable.cpp (original)
+++ lld/trunk/wasm/SymbolTable.cpp Wed Dec 20 18:43:39 2017
@@ -83,15 +83,7 @@ static const WasmSignature *getFunctionS
                                            const WasmSymbol &Sym) {
   DEBUG(dbgs() << "getFunctionSig: " << Sym.Name << "\n");
   const WasmObjectFile *WasmObj = Obj.getWasmObj();
-  uint32_t FunctionType;
-  if (Obj.isImportedFunction(Sym.ElementIndex)) {
-    const WasmImport &Import = WasmObj->imports()[Sym.ImportIndex];
-    FunctionType = Import.SigIndex;
-  } else {
-    uint32_t FunctionIndex = Sym.ElementIndex - Obj.NumFunctionImports();
-    FunctionType = WasmObj->functionTypes()[FunctionIndex];
-  }
-  return &WasmObj->types()[FunctionType];
+  return &WasmObj->types()[Sym.FunctionType];
 }
 
 // Check the type of new symbol matches that of the symbol is replacing.




More information about the llvm-commits mailing list