[llvm-commits] [llvm] r85081 - in /llvm/trunk: lib/AsmParser/LLParser.cpp test/CodeGen/CPP/llvm2cpp.ll test/CodeGen/X86/x86-64-pic-10.ll

Chris Lattner sabre at nondot.org
Sun Oct 25 16:22:50 PDT 2009


Author: lattner
Date: Sun Oct 25 18:22:50 2009
New Revision: 85081

URL: http://llvm.org/viewvc/llvm-project?rev=85081&view=rev
Log:
fix PR5295 where the .ll parser didn't reject a function after a global
or global after a function with conflicting names.  Update some testcases
that were accidentally depending on this behavior.

Modified:
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/test/CodeGen/CPP/llvm2cpp.ll
    llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=85081&r1=85080&r2=85081&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Sun Oct 25 18:22:50 2009
@@ -603,8 +603,7 @@
 
   // See if this value already exists in the symbol table.  If so, it is either
   // a redefinition or a definition of a forward reference.
-  if (GlobalValue *Val =
-        cast_or_null<GlobalValue>(M->getValueSymbolTable().lookup(Name))) {
+  if (GlobalValue *Val = M->getNamedValue(Name)) {
     // See if this was a redefinition.  If so, there is no entry in
     // ForwardRefVals.
     std::map<std::string, std::pair<GlobalValue*, LocTy> >::iterator
@@ -671,9 +670,11 @@
 
   // See if the global was forward referenced, if so, use the global.
   if (!Name.empty()) {
-    if ((GV = M->getGlobalVariable(Name, true)) &&
-        !ForwardRefVals.erase(Name))
-      return Error(NameLoc, "redefinition of global '@" + Name + "'");
+    if (GlobalValue *GVal = M->getNamedValue(Name)) {
+      if (!ForwardRefVals.erase(Name) || !isa<GlobalValue>(GVal))
+        return Error(NameLoc, "redefinition of global '@" + Name + "'");
+      GV = cast<GlobalVariable>(GVal);
+    }
   } else {
     std::map<unsigned, std::pair<GlobalValue*, LocTy> >::iterator
       I = ForwardRefValIDs.find(NumberedVals.size());
@@ -2563,6 +2564,8 @@
              AI != AE; ++AI)
           AI->setName("");
       }
+    } else if (M->getNamedValue(FunctionName)) {
+      return Error(NameLoc, "redefinition of function '@" + FunctionName + "'");
     }
 
   } else {

Modified: llvm/trunk/test/CodeGen/CPP/llvm2cpp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CPP/llvm2cpp.ll?rev=85081&r1=85080&r2=85081&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/CPP/llvm2cpp.ll (original)
+++ llvm/trunk/test/CodeGen/CPP/llvm2cpp.ll Sun Oct 25 18:22:50 2009
@@ -273,7 +273,7 @@
 @A = global i32* @B		; <i32**> [#uses=0]
 @B = global i32 7		; <i32*> [#uses=1]
 
-define void @X() {
+define void @test12312() {
 	ret void
 }
 ; ModuleID = 'global_section.ll'

Modified: llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll?rev=85081&r1=85080&r2=85081&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll (original)
+++ llvm/trunk/test/CodeGen/X86/x86-64-pic-10.ll Sun Oct 25 18:22:50 2009
@@ -3,7 +3,7 @@
 
 @g = alias weak i32 ()* @f
 
-define void @g() {
+define void @h() {
 entry:
 	%tmp31 = call i32 @g()
         ret void





More information about the llvm-commits mailing list