[llvm] r360402 - [WebAssembly] Don't assume that strongly defined symbols are DSO-local

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu May 9 18:52:09 PDT 2019


Author: sbc
Date: Thu May  9 18:52:08 2019
New Revision: 360402

URL: http://llvm.org/viewvc/llvm-project?rev=360402&view=rev
Log:
[WebAssembly] Don't assume that strongly defined symbols are DSO-local

The current PIC model for WebAssembly is more like ELF in that it
allows symbol interposition.

This means that more functions end up being addressed via the GOT
and fewer directly added to the wasm table.

One effect is a reduction in the number of wasm table entries similar
to the previous attempt in https://reviews.llvm.org/D61539 which was
reverted.

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

Modified:
    llvm/trunk/lib/Target/TargetMachine.cpp
    llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll

Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=360402&r1=360401&r2=360402&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Thu May  9 18:52:08 2019
@@ -167,13 +167,13 @@ bool TargetMachine::shouldAssumeDSOLocal
   if (GV && !GV->hasDefaultVisibility())
     return true;
 
-  if (TT.isOSBinFormatMachO() || TT.isOSBinFormatWasm()) {
+  if (TT.isOSBinFormatMachO()) {
     if (RM == Reloc::Static)
       return true;
     return GV && GV->isStrongDefinitionForLinker();
   }
 
-  assert(TT.isOSBinFormatELF());
+  assert(TT.isOSBinFormatELF() || TT.isOSBinFormatWasm());
   assert(RM != Reloc::DynamicNoPIC);
 
   bool IsExecutable =
@@ -201,7 +201,7 @@ bool TargetMachine::shouldAssumeDSOLocal
       return true;
   }
 
-  // ELF supports preemption of other symbols.
+  // ELF & wasm support preemption of other symbols.
   return false;
 }
 

Modified: llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll?rev=360402&r1=360401&r2=360402&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll Thu May  9 18:52:08 2019
@@ -7,7 +7,7 @@ declare i32 @foo()
 declare i32 @bar()
 declare hidden i32 @hidden_function()
 
- at indirect_func = global i32 ()* @foo
+ at indirect_func = hidden global i32 ()* @foo
 @alias_func = hidden alias i32 (), i32 ()* @local_function
 
 define i32 @local_function() {




More information about the llvm-commits mailing list