summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-06-22 20:29:42 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-06-22 20:29:42 +0000
commit6d88fde3afcddbc7093e657eae23fdf23437b1db (patch)
treec94289078301e2e2194b6c843ac77d388d8be575 /llvm/lib/Transforms
parent4a07bf63727fedea6441d5ccca8dbe26071a7c0e (diff)
downloadbcm5719-llvm-6d88fde3afcddbc7093e657eae23fdf23437b1db.tar.gz
bcm5719-llvm-6d88fde3afcddbc7093e657eae23fdf23437b1db.zip
IR: Introduce Module::global_objects().
This is a convenience iterator that allows clients to enumerate the GlobalObjects within a Module. Also start using it in a few places where it is obviously the right thing to use. Differential Revision: http://reviews.llvm.org/D21580 llvm-svn: 273470
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalDCE.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp
index f30e69ccbcd..4c74698a1b6 100644
--- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp
@@ -96,21 +96,14 @@ PreservedAnalyses GlobalDCEPass::run(Module &M, ModuleAnalysisManager &) {
ComdatMembers.insert(std::make_pair(C, &GA));
// Loop over the module, adding globals which are obviously necessary.
- for (Function &F : M) {
- Changed |= RemoveUnusedGlobalValue(F);
- // Functions with external linkage are needed if they have a body
- if (!F.isDeclaration() && !F.hasAvailableExternallyLinkage())
- if (!F.isDiscardableIfUnused())
- GlobalIsNeeded(&F);
- }
-
- for (GlobalVariable &GV : M.globals()) {
- Changed |= RemoveUnusedGlobalValue(GV);
+ for (GlobalObject &GO : M.global_objects()) {
+ Changed |= RemoveUnusedGlobalValue(GO);
+ // Functions with external linkage are needed if they have a body.
// Externally visible & appending globals are needed, if they have an
// initializer.
- if (!GV.isDeclaration() && !GV.hasAvailableExternallyLinkage())
- if (!GV.isDiscardableIfUnused())
- GlobalIsNeeded(&GV);
+ if (!GO.isDeclaration() && !GO.hasAvailableExternallyLinkage())
+ if (!GO.isDiscardableIfUnused())
+ GlobalIsNeeded(&GO);
}
for (GlobalAlias &GA : M.aliases()) {
OpenPOWER on IntegriCloud