@@ -756,12 +756,12 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
756
756
// Determine whether linkage of these two globals follows the source
757
757
// module's definition or the destination module's definition.
758
758
GlobalValue::LinkageTypes NewLinkage = GlobalValue::InternalLinkage;
759
- HasUnnamedAddr = HasUnnamedAddr && DGV->hasUnnamedAddr ();
760
759
GlobalValue::VisibilityTypes NV;
761
760
bool LinkFromSrc = false ;
762
761
if (getLinkageResult (DGV, SGV, NewLinkage, NV, LinkFromSrc))
763
762
return true ;
764
763
NewVisibility = NV;
764
+ HasUnnamedAddr = HasUnnamedAddr && DGV->hasUnnamedAddr ();
765
765
766
766
// If we're not linking from the source, then keep the definition that we
767
767
// have.
@@ -817,6 +817,7 @@ bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
817
817
bool ModuleLinker::linkFunctionProto (Function *SF) {
818
818
GlobalValue *DGV = getLinkedToGlobal (SF);
819
819
llvm::Optional<GlobalValue::VisibilityTypes> NewVisibility;
820
+ bool HasUnnamedAddr = SF->hasUnnamedAddr ();
820
821
821
822
if (DGV) {
822
823
GlobalValue::LinkageTypes NewLinkage = GlobalValue::InternalLinkage;
@@ -825,11 +826,13 @@ bool ModuleLinker::linkFunctionProto(Function *SF) {
825
826
if (getLinkageResult (DGV, SF, NewLinkage, NV, LinkFromSrc))
826
827
return true ;
827
828
NewVisibility = NV;
829
+ HasUnnamedAddr = HasUnnamedAddr && DGV->hasUnnamedAddr ();
828
830
829
831
if (!LinkFromSrc) {
830
832
// Set calculated linkage
831
833
DGV->setLinkage (NewLinkage);
832
834
DGV->setVisibility (*NewVisibility);
835
+ DGV->setUnnamedAddr (HasUnnamedAddr);
833
836
834
837
// Make sure to remember this mapping.
835
838
ValueMap[SF] = ConstantExpr::getBitCast (DGV, TypeMap.get (SF->getType ()));
@@ -857,6 +860,7 @@ bool ModuleLinker::linkFunctionProto(Function *SF) {
857
860
copyGVAttributes (NewDF, SF);
858
861
if (NewVisibility)
859
862
NewDF->setVisibility (*NewVisibility);
863
+ NewDF->setUnnamedAddr (HasUnnamedAddr);
860
864
861
865
if (DGV) {
862
866
// Any uses of DF need to change to NewDF, with cast.
0 commit comments