From b55344a7434712dd066a7e64d2c9691ebd73503e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 10 May 2019 01:52:08 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360402 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/TargetMachine.cpp | 6 +++--- test/CodeGen/WebAssembly/call-pic.ll | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 5b2bdc37af8..fd70b836421 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -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; } diff --git a/test/CodeGen/WebAssembly/call-pic.ll b/test/CodeGen/WebAssembly/call-pic.ll index b319ea4924f..53a397ac769 100644 --- a/test/CodeGen/WebAssembly/call-pic.ll +++ b/test/CodeGen/WebAssembly/call-pic.ll @@ -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() { -- 2.11.0