]> granicus.if.org Git - llvm/commitdiff
[WebAssembly] Don't assume that strongly defined symbols are DSO-local
authorSam Clegg <sbc@chromium.org>
Fri, 10 May 2019 01:52:08 +0000 (01:52 +0000)
committerSam Clegg <sbc@chromium.org>
Fri, 10 May 2019 01:52:08 +0000 (01:52 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360402 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/TargetMachine.cpp
test/CodeGen/WebAssembly/call-pic.ll

index 5b2bdc37af88ab63016939fa447a18204c64423f..fd70b836421a6148213e5721e604fbdf55098184 100644 (file)
@@ -167,13 +167,13 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M,
   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(const Module &M,
       return true;
   }
 
-  // ELF supports preemption of other symbols.
+  // ELF & wasm support preemption of other symbols.
   return false;
 }
 
index b319ea4924f308a11901f9dfac2ba5bac7e75b02..53a397ac76960adc6c5e4cef3730a41ba2e6a5fa 100644 (file)
@@ -7,7 +7,7 @@ declare i32 @foo()
 declare i32 @bar()
 declare hidden i32 @hidden_function()
 
-@indirect_func = global i32 ()* @foo
+@indirect_func = hidden global i32 ()* @foo
 @alias_func = hidden alias i32 (), i32 ()* @local_function
 
 define i32 @local_function() {