diff options
author | Chris Lattner <sabre@nondot.org> | 2004-12-08 03:28:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-12-08 03:28:51 +0000 |
commit | 79a993ea0d0b4d51871c718d30a5fed4ed688461 (patch) | |
tree | 1bd0321640d4a3bdbb396c3f66ee40ad7b9b5d54 /llvm/lib | |
parent | 040c3868b39e74508eb68af29e04dde938948477 (diff) | |
download | bcm5719-llvm-79a993ea0d0b4d51871c718d30a5fed4ed688461.tar.gz bcm5719-llvm-79a993ea0d0b4d51871c718d30a5fed4ed688461.zip |
Add a disgusting hack to work around a libstdc++ issue. This code should
be removed when PR400 is resolved.
llvm-svn: 18610
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index d58acbec81c..02d2c186df0 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -425,6 +425,20 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src, return false; } +// Gross hack, see call sites. +static void CoutHack(GlobalVariable *GV1, GlobalVariable *GV2) { + const Type *GV1Ty = GV1->getType()->getElementType(); + const Type *GV2Ty = GV2->getType()->getElementType(); + + if (GV1->isExternal() && isa<StructType>(GV1Ty) && + GV2->hasInitializer() && GV2->hasExternalLinkage() && + GV2->getInitializer()->isNullValue() && isa<ArrayType>(GV2Ty) && + cast<ArrayType>(GV2Ty)->getElementType() == Type::SByteTy) { + GV1->setInitializer(Constant::getNullValue(GV1Ty)); + GV2->setInitializer(0); + } +} + // LinkGlobals - Loop through the global variables in the src module and merge // them into the dest module. static bool LinkGlobals(Module *Dest, Module *Src, @@ -459,6 +473,15 @@ static bool LinkGlobals(Module *Dest, Module *Src, assert(SGV->hasInitializer() || SGV->hasExternalLinkage() && "Global must either be external or have an initializer!"); + // This is a gross hack to handle cin/cout until PR400 is implemented. If + // we are linking an external struct against a zero-initialized array of + // sbytes, move the initializer from the array to the struct so we keep the + // struct type. + if (DGV) { + CoutHack(DGV, SGV); + CoutHack(SGV, DGV); + } + GlobalValue::LinkageTypes NewLinkage; bool LinkFromSrc; if (GetLinkageResult(DGV, SGV, NewLinkage, LinkFromSrc, Err)) |