diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2016-01-15 03:34:06 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2016-01-15 03:34:06 +0000 |
commit | 26907f9236d84d2ccc55a04c8fd1ceb63d34d112 (patch) | |
tree | 463d771a4d96d93018793417947fc3ea0714adea /clang/lib/CodeGen | |
parent | 4769517b7b5745853db9cc702862aacce580ac81 (diff) | |
download | bcm5719-llvm-26907f9236d84d2ccc55a04c8fd1ceb63d34d112.tar.gz bcm5719-llvm-26907f9236d84d2ccc55a04c8fd1ceb63d34d112.zip |
[CodeGen] Attach attributes to thread local wrapper function.
This commit is a follow-up to r251734, r251476, and r249735, which fixes
a bug where function attributes were not attached to thread local
wrapper functions.
rdar://problem/20828324
llvm-svn: 257865
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index e02c8dc3a86..8b6322a4b75 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -2178,17 +2178,29 @@ ItaniumCXXABI::getOrCreateThreadLocalWrapper(const VarDecl *VD, getMangleContext().mangleItaniumThreadLocalWrapper(VD, Out); } + // FIXME: If VD is a definition, we should regenerate the function attributes + // before returning. if (llvm::Value *V = CGM.getModule().getNamedValue(WrapperName)) return cast<llvm::Function>(V); - llvm::Type *RetTy = Val->getType(); - if (VD->getType()->isReferenceType()) - RetTy = RetTy->getPointerElementType(); + QualType RetQT = VD->getType(); + if (RetQT->isReferenceType()) + RetQT = RetQT.getNonReferenceType(); + + const CGFunctionInfo &FI = CGM.getTypes().arrangeFreeFunctionDeclaration( + getContext().getPointerType(RetQT), FunctionArgList(), + FunctionType::ExtInfo(), false); - llvm::FunctionType *FnTy = llvm::FunctionType::get(RetTy, false); + llvm::FunctionType *FnTy = CGM.getTypes().GetFunctionType(FI); llvm::Function *Wrapper = llvm::Function::Create(FnTy, getThreadLocalWrapperLinkage(VD, CGM), WrapperName.str(), &CGM.getModule()); + + CGM.SetLLVMFunctionAttributes(nullptr, FI, Wrapper); + + if (VD->hasDefinition()) + CGM.SetLLVMFunctionAttributesForDefinition(nullptr, Wrapper); + // Always resolve references to the wrapper at link time. if (!Wrapper->hasLocalLinkage() && !(isThreadWrapperReplaceable(VD, CGM) && !llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) && @@ -2264,6 +2276,10 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs( Init = llvm::Function::Create( FnTy, llvm::GlobalVariable::ExternalWeakLinkage, InitFnName.str(), &CGM.getModule()); + const CGFunctionInfo &FI = CGM.getTypes().arrangeFreeFunctionDeclaration( + CGM.getContext().VoidTy, FunctionArgList(), FunctionType::ExtInfo(), + false); + CGM.SetLLVMFunctionAttributes(nullptr, FI, cast<llvm::Function>(Init)); } if (Init) |