From c3404fd9b0a560741b38adfece906fcbccb8ecc0 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 6 Mar 2014 01:10:46 +0000 Subject: [PATCH] Construct GlobalValues with the correct linkage instead of using setLinkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203052 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGObjCMac.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index d0419ec163..0cb38f27aa 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -2660,8 +2660,8 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) { Values); if (Entry) { - // Already created, fix the linkage and update the initializer. - Entry->setLinkage(llvm::GlobalValue::PrivateLinkage); + // Already created, update the initializer. + assert(Entry->getLinkage() == llvm::GlobalValue::PrivateLinkage); Entry->setInitializer(Init); } else { Entry = @@ -6242,10 +6242,9 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef( // reference or not. At module finalization we add the empty // contents for protocols which were referenced but never defined. Entry = - new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, false, - llvm::GlobalValue::ExternalLinkage, - 0, - "\01l_OBJC_PROTOCOL_$_" + PD->getName()); + new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, + false, llvm::GlobalValue::WeakAnyLinkage, 0, + "\01l_OBJC_PROTOCOL_$_" + PD->getName()); Entry->setSection("__DATA,__datacoal_nt,coalesced"); } @@ -6358,8 +6357,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( Values); if (Entry) { - // Already created, fix the linkage and update the initializer. - Entry->setLinkage(llvm::GlobalValue::WeakAnyLinkage); + // Already created, update the initializer. + assert(Entry->getLinkage() == llvm::GlobalValue::WeakAnyLinkage); Entry->setInitializer(Init); } else { Entry = -- 2.40.0