summaryrefslogtreecommitdiffstats
path: root/llvm/lib/LTO
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-04-13 05:36:06 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-04-13 05:36:06 +0000
commitdeee003a586f7cf2562c89112b0e5bc7662d139e (patch)
tree009a899c4288cf9bda8c75cc38e71f5cbc3de74a /llvm/lib/LTO
parent59269a874f23334529e17df27f35f7e38f282a71 (diff)
downloadbcm5719-llvm-deee003a586f7cf2562c89112b0e5bc7662d139e.tar.gz
bcm5719-llvm-deee003a586f7cf2562c89112b0e5bc7662d139e.zip
Move "ExternalSymbols" out of LTOInternalize (NFC)
This is not really related to internalization per se. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266170
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp20
-rw-r--r--llvm/lib/LTO/LTOInternalize.cpp17
-rw-r--r--llvm/lib/LTO/LTOInternalize.h3
3 files changed, 22 insertions, 18 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index f81a39dac1b..bfa534efdeb 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -337,6 +337,23 @@ void LTOCodeGenerator::applyScopeRestrictions() {
if (ScopeRestrictionsDone || !ShouldInternalize)
return;
+ if (ShouldRestoreGlobalsLinkage) {
+ // Record the linkage type of non-local symbols so they can be restored
+ // prior
+ // to module splitting.
+ auto RecordLinkage = [&](const GlobalValue &GV) {
+ if (!GV.hasAvailableExternallyLinkage() && !GV.hasLocalLinkage() &&
+ GV.hasName())
+ ExternalSymbols.insert(std::make_pair(GV.getName(), GV.getLinkage()));
+ };
+ for (auto &GV : *MergedModule)
+ RecordLinkage(GV);
+ for (auto &GV : MergedModule->globals())
+ RecordLinkage(GV);
+ for (auto &GV : MergedModule->aliases())
+ RecordLinkage(GV);
+ }
+
// Declare a callback for the internalize pass that will ask for every
// candidate GlobalValue if it can be internalized or not.
Mangler Mangler;
@@ -352,8 +369,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
return MustPreserveSymbols.count(MangledName);
};
- LTOInternalize(*MergedModule, *TargetMach, MustPreserveGV, AsmUndefinedRefs,
- (ShouldRestoreGlobalsLinkage ? &ExternalSymbols : nullptr));
+ LTOInternalize(*MergedModule, *TargetMach, MustPreserveGV, AsmUndefinedRefs);
ScopeRestrictionsDone = true;
}
diff --git a/llvm/lib/LTO/LTOInternalize.cpp b/llvm/lib/LTO/LTOInternalize.cpp
index f4a4f6bc67c..46b13f68c46 100644
--- a/llvm/lib/LTO/LTOInternalize.cpp
+++ b/llvm/lib/LTO/LTOInternalize.cpp
@@ -28,10 +28,8 @@ class ComputeAsmUsed {
public:
ComputeAsmUsed(const StringSet<> &AsmUndefinedRefs, const TargetMachine &TM,
const Module &TheModule,
- StringMap<GlobalValue::LinkageTypes> *ExternalSymbols,
SmallPtrSetImpl<const GlobalValue *> &AsmUsed)
- : AsmUndefinedRefs(AsmUndefinedRefs), TM(TM),
- ExternalSymbols(ExternalSymbols), AsmUsed(AsmUsed) {
+ : AsmUndefinedRefs(AsmUndefinedRefs), TM(TM), AsmUsed(AsmUsed) {
accumulateAndSortLibcalls(TheModule);
for (const Function &F : TheModule)
findAsmUses(F);
@@ -51,7 +49,6 @@ private:
std::vector<StringRef> Libcalls;
// Output
- StringMap<GlobalValue::LinkageTypes> *ExternalSymbols;
SmallPtrSetImpl<const GlobalValue *> &AsmUsed;
// Collect names of runtime library functions. User-defined functions with the
@@ -114,13 +111,6 @@ private:
if (isa<Function>(GV) &&
std::binary_search(Libcalls.begin(), Libcalls.end(), GV.getName()))
AsmUsed.insert(&GV);
-
- // Record the linkage type of non-local symbols so they can be restored
- // prior
- // to module splitting.
- if (ExternalSymbols && !GV.hasAvailableExternallyLinkage() &&
- !GV.hasLocalLinkage() && GV.hasName())
- ExternalSymbols->insert(std::make_pair(GV.getName(), GV.getLinkage()));
}
};
@@ -142,10 +132,9 @@ static void findUsedValues(GlobalVariable *LLVMUsed,
void llvm::LTOInternalize(
Module &TheModule, const TargetMachine &TM,
const std::function<bool(const GlobalValue &)> &MustPreserveSymbols,
- const StringSet<> &AsmUndefinedRefs,
- StringMap<GlobalValue::LinkageTypes> *ExternalSymbols) {
+ const StringSet<> &AsmUndefinedRefs) {
SmallPtrSet<const GlobalValue *, 8> AsmUsed;
- ComputeAsmUsed(AsmUndefinedRefs, TM, TheModule, ExternalSymbols, AsmUsed);
+ ComputeAsmUsed(AsmUndefinedRefs, TM, TheModule, AsmUsed);
GlobalVariable *LLVMCompilerUsed =
TheModule.getGlobalVariable("llvm.compiler.used");
diff --git a/llvm/lib/LTO/LTOInternalize.h b/llvm/lib/LTO/LTOInternalize.h
index 6d79866fdba..ec104c13b4a 100644
--- a/llvm/lib/LTO/LTOInternalize.h
+++ b/llvm/lib/LTO/LTOInternalize.h
@@ -26,8 +26,7 @@ class TargetMachine;
void LTOInternalize(
Module &TheModule, const TargetMachine &TM,
const std::function<bool(const GlobalValue &)> &MustPreserveSymbols,
- const StringSet<> &AsmUndefinedRefs,
- StringMap<GlobalValue::LinkageTypes> *ExternalSymbols);
+ const StringSet<> &AsmUndefinedRefs);
}
#endif // LLVM_LTO_LTOINTERNALIZE_H
OpenPOWER on IntegriCloud