From b555a767baf4a1058bc6e4e05acbbee9e55d0e26 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. llvm-svn: 164864 --- clang/lib/CodeGen/CodeGenModule.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 164031a5038..d09c1c32606 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/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