From 846c2833ecaaffc0114282b77d3b5dacb44a01fe Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 29 Apr 2014 06:18:53 +0000 Subject: CodeGen: Reference temporaries inherit visibility Reference temporaries inherited many properties from the variable that they correspond to but visibility wasn't one of them. llvm-svn: 207496 --- clang/lib/CodeGen/CodeGenModule.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index bed949d..6103933 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2865,6 +2865,8 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary( // Create a global variable for this lifetime-extended temporary. llvm::GlobalValue::LinkageTypes Linkage = getLLVMLinkageVarDefinition(VD, Constant); + // There is no need for this temporary to have global linkage if the global + // variable has external linkage. if (Linkage == llvm::GlobalVariable::ExternalLinkage) Linkage = llvm::GlobalVariable::PrivateLinkage; unsigned AddrSpace = GetGlobalVarAddressSpace( @@ -2873,6 +2875,7 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalTemporary( getModule(), Type, Constant, Linkage, InitialValue, Name.c_str(), /*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal, AddrSpace); + setGlobalVisibility(GV, VD); GV->setAlignment( getContext().getTypeAlignInChars(MaterializedType).getQuantity()); if (VD->getTLSKind()) -- cgit v1.1