summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalMerge.cpp
diff options
context:
space:
mode:
authorHaicheng Wu <haicheng@codeaurora.org>2018-05-19 18:00:02 +0000
committerHaicheng Wu <haicheng@codeaurora.org>2018-05-19 18:00:02 +0000
commit69ba0613f2b9ae20fc00fc547fd125d52629d5a6 (patch)
treea12a88faf0947c93cc6ce5f2d3b6c9ee2ff367a4 /llvm/lib/CodeGen/GlobalMerge.cpp
parent9968e0dd4975d3939e7810ac9e6c52cea7f1aeb1 (diff)
downloadbcm5719-llvm-69ba0613f2b9ae20fc00fc547fd125d52629d5a6.tar.gz
bcm5719-llvm-69ba0613f2b9ae20fc00fc547fd125d52629d5a6.zip
[GlobalMerge] Exit early if only one global is to be merged
To save some compilation time and prevent some unnecessary changes. Differential Revision: https://reviews.llvm.org/D46640 llvm-svn: 332813
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