Duncan pointed out that the Extended case in getTypeForMVT could
[oota-llvm.git] / lib / VMCore / Module.cpp
index 429cf1a4c69508066e17a9f8569a22ce7a21871e..b95f6e3fa8661fd2a95773ebe7a260a465394234 100644 (file)
@@ -88,11 +88,6 @@ Module::~Module() {
   delete TypeSymTab;
 }
 
-// Module::dump() - Allow printing from debugger
-void Module::dump() const {
-  print(*cerr.stream());
-}
-
 /// Target endian information...
 Module::Endianness Module::getEndianness() const {
   std::string temp = DataLayout;
@@ -156,10 +151,12 @@ Constant *Module::getOrInsertFunction(const std::string &Name,
 
   // Okay, the function exists.  Does it have externally visible linkage?
   if (F->hasInternalLinkage()) {
-    // Rename the function.
-    F->setName(SymTab.getUniqueName(F->getName()));
+    // Clear the function's name.
+    F->setName("");
     // Retry, now there won't be a conflict.
-    return getOrInsertFunction(Name, Ty);
+    Constant *NewF = getOrInsertFunction(Name, Ty);
+    F->setName(&Name[0], Name.size());
+    return NewF;
   }
 
   // If the function exists but has the wrong type, return a bitcast to the
@@ -201,6 +198,11 @@ Function *Module::getFunction(const std::string &Name) const {
   return dyn_cast_or_null<Function>(SymTab.lookup(Name));
 }
 
+Function *Module::getFunction(const char *Name) const {
+  const ValueSymbolTable &SymTab = getValueSymbolTable();
+  return dyn_cast_or_null<Function>(SymTab.lookup(Name, Name+strlen(Name)));
+}
+
 //===----------------------------------------------------------------------===//
 // Methods for easy access to the global variables in the module.
 //