diff options
-rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 9 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 4 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 14 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 9 |
4 files changed, 18 insertions, 18 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 983cb9224ad..afeb090d5b5 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -106,8 +106,7 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, // The alias will use the linkage of the referrent. If we can't // support aliases with that linkage, fail. - llvm::GlobalValue::LinkageTypes Linkage - = getFunctionLinkage(cast<FunctionDecl>(AliasDecl.getDecl())); + llvm::GlobalValue::LinkageTypes Linkage = getFunctionLinkage(AliasDecl); switch (Linkage) { // We can definitely emit aliases to definitions with external linkage. @@ -132,7 +131,7 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, } llvm::GlobalValue::LinkageTypes TargetLinkage - = getFunctionLinkage(cast<FunctionDecl>(TargetDecl.getDecl())); + = getFunctionLinkage(TargetDecl); if (llvm::GlobalValue::isWeakForLinker(TargetLinkage)) return true; @@ -203,7 +202,7 @@ void CodeGenModule::EmitCXXConstructor(const CXXConstructorDecl *ctor, llvm::Function *fn = cast<llvm::Function>(GetAddrOfCXXConstructor(ctor, ctorType, &fnInfo)); - setFunctionLinkage(ctor, fn); + setFunctionLinkage(GlobalDecl(ctor, ctorType), fn); CodeGenFunction(*this).GenerateCode(GlobalDecl(ctor, ctorType), fn, fnInfo); @@ -267,7 +266,7 @@ void CodeGenModule::EmitCXXDestructor(const CXXDestructorDecl *dtor, llvm::Function *fn = cast<llvm::Function>(GetAddrOfCXXDestructor(dtor, dtorType, &fnInfo)); - setFunctionLinkage(dtor, fn); + setFunctionLinkage(GlobalDecl(dtor, dtorType), fn); CodeGenFunction(*this).GenerateCode(GlobalDecl(dtor, dtorType), fn, fnInfo); diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 9a345cf4724..b1072b47213 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -379,7 +379,7 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, FinishFunction(); // Set the right linkage. - CGM.setFunctionLinkage(MD, Fn); + CGM.setFunctionLinkage(GD, Fn); // Set the right visibility. setThunkVisibility(CGM, MD, Thunk, Fn); @@ -437,7 +437,7 @@ void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk, "Function should have available_externally linkage!"); // Change the linkage. - CGM.setFunctionLinkage(cast<CXXMethodDecl>(GD.getDecl()), ThunkFn); + CGM.setFunctionLinkage(GD, ThunkFn); return; } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4d64624dbcb..d49fc0b0315 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -509,7 +509,8 @@ void CodeGenModule::EmitCtorList(const CtorList &Fns, const char *GlobalName) { } llvm::GlobalValue::LinkageTypes -CodeGenModule::getFunctionLinkage(const FunctionDecl *D) { +CodeGenModule::getFunctionLinkage(GlobalDecl GD) { + const FunctionDecl *D = cast<FunctionDecl>(GD.getDecl()); GVALinkage Linkage = getContext().GetGVALinkageForFunction(D); if (Linkage == GVA_Internal) @@ -1230,9 +1231,10 @@ CodeGenModule::isTriviallyRecursive(const FunctionDecl *FD) { } bool -CodeGenModule::shouldEmitFunction(const FunctionDecl *F) { - if (getFunctionLinkage(F) != llvm::Function::AvailableExternallyLinkage) +CodeGenModule::shouldEmitFunction(GlobalDecl GD) { + if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage) return true; + const FunctionDecl *F = cast<FunctionDecl>(GD.getDecl()); if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr<AlwaysInlineAttr>() && !F->hasAttr<ForceInlineAttr>()) return false; @@ -1268,10 +1270,10 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { Context.getSourceManager(), "Generating code for declaration"); - if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) { + if (isa<FunctionDecl>(D)) { // At -O0, don't generate IR for functions with available_externally // linkage. - if (!shouldEmitFunction(Function)) + if (!shouldEmitFunction(GD)) return; if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) { @@ -2177,7 +2179,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { // want to propagate this information down (e.g. to local static // declarations). llvm::Function *Fn = cast<llvm::Function>(Entry); - setFunctionLinkage(D, Fn); + setFunctionLinkage(GD, Fn); // FIXME: this is redundant with part of SetFunctionDefinitionAttributes setGlobalVisibility(Fn, D); diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index aa48cce08b8..b2ff60deff2 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -386,7 +386,7 @@ class CodeGenModule : public CodeGenTypeCache { void createCUDARuntime(); bool isTriviallyRecursive(const FunctionDecl *F); - bool shouldEmitFunction(const FunctionDecl *F); + bool shouldEmitFunction(GlobalDecl GD); /// @name Cache for Blocks Runtime Globals /// @{ @@ -924,11 +924,10 @@ public: /// \brief Appends a dependent lib to the "Linker Options" metadata value. void AddDependentLib(StringRef Lib); - llvm::GlobalVariable::LinkageTypes - getFunctionLinkage(const FunctionDecl *FD); + llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD); - void setFunctionLinkage(const FunctionDecl *FD, llvm::GlobalValue *V) { - V->setLinkage(getFunctionLinkage(FD)); + void setFunctionLinkage(GlobalDecl GD, llvm::GlobalValue *V) { + V->setLinkage(getFunctionLinkage(GD)); } /// getVTableLinkage - Return the appropriate linkage for the vtable, VTT, |