diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-04-26 17:53:39 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-04-26 17:53:39 +0000 |
commit | fa58f7528e81c1a6d055cd93efe2a2f0364e0a3d (patch) | |
tree | f4126113b71764527f836220c52235eb39bc7e49 /llvm/lib/Object/IRSymtab.cpp | |
parent | c9f0a4f1eccf55c1f588c8d7e966c677a1baf781 (diff) | |
download | bcm5719-llvm-fa58f7528e81c1a6d055cd93efe2a2f0364e0a3d.tar.gz bcm5719-llvm-fa58f7528e81c1a6d055cd93efe2a2f0364e0a3d.zip |
LTO: Mark undefined module asm symbols as used.
Marking them as used causes them to be considered visible outside of LTO. This
prevents the symbols from being internalized or discarded, either by GlobalDCE
or by summary-based dead stripping in ThinLTO.
This change makes it unnecessary to add these symbols to llvm.compiler.used
in the backend, as the symbols are kept alive by virtue of being external,
so remove the backend code that handles that.
Fixes PR32798.
Differential Revision: https://reviews.llvm.org/D32544
llvm-svn: 301438
Diffstat (limited to 'llvm/lib/Object/IRSymtab.cpp')
-rw-r--r-- | llvm/lib/Object/IRSymtab.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index 367b1e8fb63..5f0837882d6 100644 --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -163,6 +163,9 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab, Sym.ComdatIndex = -1; auto *GV = Msym.dyn_cast<GlobalValue *>(); if (!GV) { + // Undefined module asm symbols act as GC roots and are implicitly used. + if (Flags & object::BasicSymbolRef::SF_Undefined) + Sym.Flags |= 1 << storage::Symbol::FB_used; setStr(Sym.IRName, ""); return Error::success(); } |