From fa58f7528e81c1a6d055cd93efe2a2f0364e0a3d Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 26 Apr 2017 17:53:39 +0000 Subject: 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 --- llvm/lib/Object/IRSymtab.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/Object/IRSymtab.cpp') 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(); 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(); } -- cgit v1.2.3