summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-03-30 23:43:08 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-03-30 23:43:08 +0000
commit6b193966accaf54bde56ad055fe3d185e5036534 (patch)
tree5cf4017141728c6219c92acbcfe0bab8d362c74f /llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
parentc749bdc346edfcb7c43eb3fe9dc4bbb2e5c2ddb0 (diff)
downloadbcm5719-llvm-6b193966accaf54bde56ad055fe3d185e5036534.tar.gz
bcm5719-llvm-6b193966accaf54bde56ad055fe3d185e5036534.zip
ThinLTOBitcodeWriter: Use Module::global_values(). NFCI.
llvm-svn: 299132
Diffstat (limited to 'llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp32
1 files changed, 7 insertions, 25 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 978b6cfee38..4bc7004a0da 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -46,23 +46,14 @@ namespace {
std::string getModuleId(Module *M) {
MD5 Md5;
bool ExportsSymbols = false;
- auto AddGlobal = [&](GlobalValue &GV) {
+ for (auto &GV : M->global_values()) {
if (GV.isDeclaration() || GV.getName().startswith("llvm.") ||
!GV.hasExternalLinkage())
- return;
+ continue;
ExportsSymbols = true;
Md5.update(GV.getName());
Md5.update(ArrayRef<uint8_t>{0});
- };
-
- for (auto &F : *M)
- AddGlobal(F);
- for (auto &GV : M->globals())
- AddGlobal(GV);
- for (auto &GA : M->aliases())
- AddGlobal(GA);
- for (auto &IF : M->ifuncs())
- AddGlobal(IF);
+ }
if (!ExportsSymbols)
return "";
@@ -78,13 +69,13 @@ std::string getModuleId(Module *M) {
// Promote each local-linkage entity defined by ExportM and used by ImportM by
// changing visibility and appending the given ModuleId.
void promoteInternals(Module &ExportM, Module &ImportM, StringRef ModuleId) {
- auto PromoteInternal = [&](GlobalValue &ExportGV) {
+ for (auto &ExportGV : ExportM.global_values()) {
if (!ExportGV.hasLocalLinkage())
- return;
+ continue;
GlobalValue *ImportGV = ImportM.getNamedValue(ExportGV.getName());
if (!ImportGV || ImportGV->use_empty())
- return;
+ continue;
std::string NewName = (ExportGV.getName() + ModuleId).str();
@@ -94,16 +85,7 @@ void promoteInternals(Module &ExportM, Module &ImportM, StringRef ModuleId) {
ImportGV->setName(NewName);
ImportGV->setVisibility(GlobalValue::HiddenVisibility);
- };
-
- for (auto &F : ExportM)
- PromoteInternal(F);
- for (auto &GV : ExportM.globals())
- PromoteInternal(GV);
- for (auto &GA : ExportM.aliases())
- PromoteInternal(GA);
- for (auto &IF : ExportM.ifuncs())
- PromoteInternal(IF);
+ }
}
// Promote all internal (i.e. distinct) type ids used by the module by replacing
OpenPOWER on IntegriCloud