summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/FunctionResolution.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-05-31 21:57:06 +0000
committerChris Lattner <sabre@nondot.org>2003-05-31 21:57:06 +0000
commitc16e631e943c3e8460598389c3fff57d1f73c17c (patch)
tree9964f20a4c369af0d1e0287c0401823f7fd11797 /lib/Transforms/IPO/FunctionResolution.cpp
parent3ce0ea8fd8b6b02acc5828cbc90f113a3cf33207 (diff)
downloadllvm-c16e631e943c3e8460598389c3fff57d1f73c17c.tar.gz
llvm-c16e631e943c3e8460598389c3fff57d1f73c17c.tar.bz2
llvm-c16e631e943c3e8460598389c3fff57d1f73c17c.tar.xz
Fix bug: FunctionResolve/2003-05-31-AllInternalDecls.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6486 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/FunctionResolution.cpp')
-rw-r--r--lib/Transforms/IPO/FunctionResolution.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp
index 18a28895fd..7ec1745ffd 100644
--- a/lib/Transforms/IPO/FunctionResolution.cpp
+++ b/lib/Transforms/IPO/FunctionResolution.cpp
@@ -309,6 +309,23 @@ static bool ProcessGlobalsWithSameName(Module &M,
}
if (Globals.size() > 1) { // Found a multiply defined global...
+ // If there are no external declarations, and there is at most one
+ // externally visible instance of the global, then there is nothing to do.
+ //
+ bool HasExternal = false;
+ unsigned NumInstancesWithExternalLinkage = 0;
+
+ for (unsigned i = 0, e = Globals.size(); i != e; ++i) {
+ if (Globals[i]->isExternal())
+ HasExternal = true;
+ else if (!Globals[i]->hasInternalLinkage())
+ NumInstancesWithExternalLinkage++;
+ }
+
+ if (!HasExternal && NumInstancesWithExternalLinkage <= 1)
+ return false; // Nothing to do? Must have multiple internal definitions.
+
+
// We should find exactly one concrete function definition, which is
// probably the implementation. Change all of the function definitions and
// uses to use it instead.