summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-04-26 17:53:39 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-04-26 17:53:39 +0000
commitfa58f7528e81c1a6d055cd93efe2a2f0364e0a3d (patch)
treef4126113b71764527f836220c52235eb39bc7e49 /llvm/lib/LTO
parentc9f0a4f1eccf55c1f588c8d7e966c677a1baf781 (diff)
downloadbcm5719-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/LTO')
-rw-r--r--llvm/lib/LTO/LTO.cpp3
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp18
2 files changed, 2 insertions, 19 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 9782c898bf5..1bc0d7361d4 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -415,7 +415,8 @@ void LTO::addSymbolToGlobalRes(const InputFile::Symbol &Sym,
// Flag as visible outside of ThinLTO if visible from a regular object or
// if this is a reference in the regular LTO partition.
GlobalRes.VisibleOutsideThinLTO |=
- (Res.VisibleToRegularObj || (Partition == GlobalResolution::RegularLTO));
+ (Res.VisibleToRegularObj || Sym.isUsed() ||
+ Partition == GlobalResolution::RegularLTO);
}
static void writeToResolutionFile(raw_ostream &OS, InputFile *Input,
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 4bd251f727a..30447c528af 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -25,7 +25,6 @@
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Verifier.h"
#include "llvm/LTO/LTO.h"
-#include "llvm/LTO/legacy/UpdateCompilerUsed.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Object/ModuleSymbolTable.h"
#include "llvm/Passes/PassBuilder.h"
@@ -353,19 +352,6 @@ finalizeOptimizationRemarks(std::unique_ptr<tool_output_file> DiagOutputFile) {
DiagOutputFile->os().flush();
}
-static void handleAsmUndefinedRefs(Module &Mod, TargetMachine &TM) {
- // Collect the list of undefined symbols used in asm and update
- // llvm.compiler.used to prevent optimization to drop these from the output.
- StringSet<> AsmUndefinedRefs;
- ModuleSymbolTable::CollectAsmSymbols(
- Mod,
- [&AsmUndefinedRefs](StringRef Name, object::BasicSymbolRef::Flags Flags) {
- if (Flags & object::BasicSymbolRef::SF_Undefined)
- AsmUndefinedRefs.insert(Name);
- });
- updateCompilerUsed(Mod, TM, AsmUndefinedRefs);
-}
-
Error lto::backend(Config &C, AddStreamFn AddStream,
unsigned ParallelCodeGenParallelismLevel,
std::unique_ptr<Module> Mod,
@@ -377,8 +363,6 @@ Error lto::backend(Config &C, AddStreamFn AddStream,
std::unique_ptr<TargetMachine> TM =
createTargetMachine(C, Mod->getTargetTriple(), *TOrErr);
- handleAsmUndefinedRefs(*Mod, *TM);
-
// Setup optimization remarks.
auto DiagFileOrErr = lto::setupOptimizationRemarks(
Mod->getContext(), C.RemarksFilename, C.RemarksWithHotness);
@@ -416,8 +400,6 @@ Error lto::thinBackend(Config &Conf, unsigned Task, AddStreamFn AddStream,
std::unique_ptr<TargetMachine> TM =
createTargetMachine(Conf, Mod.getTargetTriple(), *TOrErr);
- handleAsmUndefinedRefs(Mod, *TM);
-
if (Conf.CodeGenOnly) {
codegen(Conf, TM.get(), AddStream, Task, Mod);
return Error::success();
OpenPOWER on IntegriCloud