summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalMerge.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/GlobalMerge.cpp')
-rw-r--r--llvm/lib/CodeGen/GlobalMerge.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/GlobalMerge.cpp b/llvm/lib/CodeGen/GlobalMerge.cpp
index cda5861f676..fbf94d2bb7f 100644
--- a/llvm/lib/CodeGen/GlobalMerge.cpp
+++ b/llvm/lib/CodeGen/GlobalMerge.cpp
@@ -445,6 +445,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
LLVM_DEBUG(dbgs() << " Trying to merge set, starts with #"
<< GlobalSet.find_first() << "\n");
+ bool Changed = false;
ssize_t i = GlobalSet.find_first();
while (i != -1) {
ssize_t j = 0;
@@ -469,6 +470,12 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
}
}
+ // Exit early if there is only one global to merge.
+ if (Tys.size() < 2) {
+ i = j;
+ continue;
+ }
+
// If merged variables doesn't have external linkage, we needn't to expose
// the symbol after merging.
GlobalValue::LinkageTypes Linkage = HasExternal
@@ -526,10 +533,11 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
NumMerged++;
}
+ Changed = true;
i = j;
}
- return true;
+ return Changed;
}
void GlobalMerge::collectUsedGlobalVariables(Module &M) {
OpenPOWER on IntegriCloud