diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-28 22:46:07 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-28 22:46:07 +0000 |
commit | b555a767baf4a1058bc6e4e05acbbee9e55d0e26 (patch) | |
tree | f6da57e020a88e2bfcb717104ec4692ca21a9642 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 538fe8f35b26b925e21a4329599c188d48264f0d (diff) | |
download | bcm5719-llvm-b555a767baf4a1058bc6e4e05acbbee9e55d0e26.tar.gz bcm5719-llvm-b555a767baf4a1058bc6e4e05acbbee9e55d0e26.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
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<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) |