[llvm-commits] [llvm] r41815 - in /llvm/trunk: lib/AsmParser/llvmAsmParser.y test/Assembler/2007-09-10-AliasFwdRef.ll

Chris Lattner sabre at nondot.org
Mon Sep 10 16:23:53 PDT 2007


Author: lattner
Date: Mon Sep 10 18:23:53 2007
New Revision: 41815

URL: http://llvm.org/viewvc/llvm-project?rev=41815&view=rev
Log:
Fix PR1645 by resolving forward alias references.

Added:
    llvm/trunk/test/Assembler/2007-09-10-AliasFwdRef.ll
Modified:
    llvm/trunk/lib/AsmParser/llvmAsmParser.y

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=41815&r1=41814&r2=41815&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Mon Sep 10 18:23:53 2007
@@ -2129,6 +2129,27 @@
                                       CurModule.CurrentModule);
     GA->setVisibility($2);
     InsertValue(GA, CurModule.Values);
+    
+    
+    // If there was a forward reference of this alias, resolve it now.
+    
+    ValID ID;
+    if (!Name.empty())
+      ID = ValID::createGlobalName(Name);
+    else
+      ID = ValID::createGlobalID(CurModule.Values.size()-1);
+    
+    if (GlobalValue *FWGV =
+          CurModule.GetForwardRefForGlobal(GA->getType(), ID)) {
+      // Replace uses of the fwdref with the actual alias.
+      FWGV->replaceAllUsesWith(GA);
+      if (GlobalVariable *GV = dyn_cast<GlobalVariable>(FWGV))
+        GV->eraseFromParent();
+      else
+        cast<Function>(FWGV)->eraseFromParent();
+    }
+    ID.destroy();
+    
     CHECK_FOR_ERROR
   }
   | TARGET TargetDefinition { 

Added: llvm/trunk/test/Assembler/2007-09-10-AliasFwdRef.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2007-09-10-AliasFwdRef.ll?rev=41815&view=auto

==============================================================================
--- llvm/trunk/test/Assembler/2007-09-10-AliasFwdRef.ll (added)
+++ llvm/trunk/test/Assembler/2007-09-10-AliasFwdRef.ll Mon Sep 10 18:23:53 2007
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | llvm-dis
+; PR1645
+
+ at __gthread_active_ptr.5335 = internal constant i8* bitcast (i32 (i32)* @__gthrw_pthread_cancel to i8*)    
+ at __gthrw_pthread_cancel = alias weak i32 (i32)* @pthread_cancel   
+
+
+
+declare extern_weak i32 @pthread_cancel(i32)





More information about the llvm-commits mailing list