From ef4d5ced04bf0b3d987e6b0e931f43125492f50c Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 28 Sep 2012 22:46:07 +0000 Subject: PR13941: Mark all virtual functions as unnamed_addr. It's not possible to observe their addresses (taking their address gives the vtable slot) so we are free to merge their definitions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164864 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 164031a503..d09c1c3260 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -588,6 +588,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D, if (isa(D) || isa(D)) F->setUnnamedAddr(true); + if (const CXXMethodDecl *MD = dyn_cast(D)) + if (MD->isVirtual()) + F->setUnnamedAddr(true); + if (LangOpts.getStackProtector() == LangOptions::SSPOn) F->addFnAttr(llvm::Attribute::StackProtect); else if (LangOpts.getStackProtector() == LangOptions::SSPReq) -- cgit v1.2.3-70-g09d2