diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-09-10 23:23:53 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-09-10 23:23:53 +0000 |
| commit | dae70d4d36fbb0c90c04457291959ea1f5f613a6 (patch) | |
| tree | 567e02e6af106bda035e722dff42c249fb1526a4 | |
| parent | ba3fdc9daf918d9fecfc173d9aef70b5c18bd549 (diff) | |
| download | bcm5719-llvm-dae70d4d36fbb0c90c04457291959ea1f5f613a6.tar.gz bcm5719-llvm-dae70d4d36fbb0c90c04457291959ea1f5f613a6.zip | |
Fix PR1645 by resolving forward alias references.
llvm-svn: 41815
| -rw-r--r-- | llvm/lib/AsmParser/llvmAsmParser.y | 21 | ||||
| -rw-r--r-- | llvm/test/Assembler/2007-09-10-AliasFwdRef.ll | 9 |
2 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/llvmAsmParser.y b/llvm/lib/AsmParser/llvmAsmParser.y index cf9e5a7a538..6364b29bcd7 100644 --- a/llvm/lib/AsmParser/llvmAsmParser.y +++ b/llvm/lib/AsmParser/llvmAsmParser.y @@ -2129,6 +2129,27 @@ Definition 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 { diff --git a/llvm/test/Assembler/2007-09-10-AliasFwdRef.ll b/llvm/test/Assembler/2007-09-10-AliasFwdRef.ll new file mode 100644 index 00000000000..b21491ba5a9 --- /dev/null +++ b/llvm/test/Assembler/2007-09-10-AliasFwdRef.ll @@ -0,0 +1,9 @@ +; RUN: llvm-as < %s | llvm-dis +; PR1645 + +@__gthread_active_ptr.5335 = internal constant i8* bitcast (i32 (i32)* @__gthrw_pthread_cancel to i8*) +@__gthrw_pthread_cancel = alias weak i32 (i32)* @pthread_cancel + + + +declare extern_weak i32 @pthread_cancel(i32) |

