Merging r142651:
------------------------------------------------------------------------
r142651 | baldrick | 2011-10-21 08:11:51 -0700 (Fri, 21 Oct 2011) | 4 lines

Functions can collide with global aliases as well as global values.  Update
this ancient code (which probably predates support for aliases in LLVM...)
Fixes PR11182.

------------------------------------------------------------------------

llvm-svn: 142680
diff --git a/dragonegg/src/Backend.cpp b/dragonegg/src/Backend.cpp
index f9d34b6..0e98dbe 100644
--- a/dragonegg/src/Backend.cpp
+++ b/dragonegg/src/Backend.cpp
@@ -1115,8 +1115,9 @@
       // in the symbol table.  If this happens, the old one must be a forward
       // decl, just replace it with a cast of the new one.
       if (FnEntry->getName() != Name) {
-        GlobalVariable *G = TheModule->getGlobalVariable(Name, true);
-        assert(G && G->isDeclaration() && "A global turned into a function?");
+        GlobalValue *G = TheModule->getNamedValue(Name);
+        assert(G && (G->isDeclaration() || G->isWeakForLinker()) &&
+               "A global turned into a function?");
 
         // Replace any uses of "G" with uses of FnEntry.
         Constant *GInNewType = TheFolder->CreateBitCast(FnEntry, G->getType());