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
This commit is contained in:
Richard Smith
2012-09-28 22:46:07 +00:00
parent 538fe8f35b
commit b555a767ba
3 changed files with 14 additions and 3 deletions

View File

@@ -588,6 +588,10 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D))
F->setUnnamedAddr(true);
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D))
if (MD->isVirtual())
F->setUnnamedAddr(true);
if (LangOpts.getStackProtector() == LangOptions::SSPOn)
F->addFnAttr(llvm::Attribute::StackProtect);
else if (LangOpts.getStackProtector() == LangOptions::SSPReq)