[llvm] r189935 - Fix linking of unnamed_addr.
Rafael EspĂndola
rafael.espindola at gmail.com
Wed Sep 4 07:29:46 PDT 2013
Hi Chris,
Just wanted to make sure you noticed this and confirm that that part
of r134829 was really unintentional.
On 4 September 2013 10:05, Rafael Espindola <rafael.espindola at gmail.com> wrote:
> Author: rafael
> Date: Wed Sep 4 09:05:09 2013
> New Revision: 189935
>
> URL: http://llvm.org/viewvc/llvm-project?rev=189935&view=rev
> Log:
> Fix linking of unnamed_addr.
>
> This was regression from r134829. When linking we have to be conservative. If
> one of the symbols has a significant address, then the result should have it
> too.
>
> Modified:
> llvm/trunk/lib/Linker/LinkModules.cpp
> llvm/trunk/test/Linker/unnamed-addr1-a.ll
>
> Modified: llvm/trunk/lib/Linker/LinkModules.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=189935&r1=189934&r2=189935&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Linker/LinkModules.cpp (original)
> +++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Sep 4 09:05:09 2013
> @@ -746,6 +746,7 @@ bool ModuleLinker::linkAppendingVarProto
> bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
> GlobalValue *DGV = getLinkedToGlobal(SGV);
> llvm::Optional<GlobalValue::VisibilityTypes> NewVisibility;
> + bool HasUnnamedAddr = SGV->hasUnnamedAddr();
>
> if (DGV) {
> // Concatenation of appending linkage variables is magic and handled later.
> @@ -755,6 +756,7 @@ bool ModuleLinker::linkGlobalProto(Globa
> // Determine whether linkage of these two globals follows the source
> // module's definition or the destination module's definition.
> GlobalValue::LinkageTypes NewLinkage = GlobalValue::InternalLinkage;
> + HasUnnamedAddr = HasUnnamedAddr && DGV->hasUnnamedAddr();
> GlobalValue::VisibilityTypes NV;
> bool LinkFromSrc = false;
> if (getLinkageResult(DGV, SGV, NewLinkage, NV, LinkFromSrc))
> @@ -768,10 +770,11 @@ bool ModuleLinker::linkGlobalProto(Globa
> if (GlobalVariable *DGVar = dyn_cast<GlobalVariable>(DGV))
> if (DGVar->isDeclaration() && SGV->isConstant() && !DGVar->isConstant())
> DGVar->setConstant(true);
> -
> - // Set calculated linkage and visibility.
> +
> + // Set calculated linkage, visibility and unnamed_addr.
> DGV->setLinkage(NewLinkage);
> DGV->setVisibility(*NewVisibility);
> + DGV->setUnnamedAddr(HasUnnamedAddr);
>
> // Make sure to remember this mapping.
> ValueMap[SGV] = ConstantExpr::getBitCast(DGV,TypeMap.get(SGV->getType()));
> @@ -797,6 +800,7 @@ bool ModuleLinker::linkGlobalProto(Globa
> copyGVAttributes(NewDGV, SGV);
> if (NewVisibility)
> NewDGV->setVisibility(*NewVisibility);
> + NewDGV->setUnnamedAddr(HasUnnamedAddr);
>
> if (DGV) {
> DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV, DGV->getType()));
>
> Modified: llvm/trunk/test/Linker/unnamed-addr1-a.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/unnamed-addr1-a.ll?rev=189935&r1=189934&r2=189935&view=diff
> ==============================================================================
> --- llvm/trunk/test/Linker/unnamed-addr1-a.ll (original)
> +++ llvm/trunk/test/Linker/unnamed-addr1-a.ll Wed Sep 4 09:05:09 2013
> @@ -10,15 +10,15 @@
> @c = common unnamed_addr global i32 0
> ; CHECK: @c = common unnamed_addr global i32 0
> @d = external global i32
> -; CHECK: @d = unnamed_addr global i32 42
> +; CHECK: @d = global i32 42
> @e = external unnamed_addr global i32
> ; CHECK: @e = unnamed_addr global i32 42
> @f = weak global i32 42
> -; CHECK: @f = unnamed_addr global i32 42
> +; CHECK: @f = global i32 42
>
> ; Other file has non-unnamed_addr definition
> @g = common unnamed_addr global i32 0
> -; CHECK: @g = common unnamed_addr global i32 0
> +; CHECK: @g = common global i32 0
> @h = external global i32
> ; CHECK: @h = global i32 42
> @i = external unnamed_addr global i32
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list