summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-03-20 00:31:07 +0000
committerReid Kleckner <reid@kleckner.net>2015-03-20 00:31:07 +0000
commit7ffc3fbb2f448e5c23da7ebe2af71fe29f92fa04 (patch)
treec113b61a83b83100bf05c1d68995422ec1446be6 /clang/lib/CodeGen/CodeGenFunction.cpp
parent6fe5fcbcbc7c9b65aaac2ea3ce0e03e8b9612812 (diff)
downloadbcm5719-llvm-7ffc3fbb2f448e5c23da7ebe2af71fe29f92fa04.tar.gz
bcm5719-llvm-7ffc3fbb2f448e5c23da7ebe2af71fe29f92fa04.zip
C++14: Disable sized deallocation by default due to ABI breakage
There are no widely deployed standard libraries providing sized deallocation functions, so we have to punt and ask the user if they want us to use sized deallocation. In the future, when such libraries are deployed, we can teach the driver to detect them and enable this feature. N3536 claimed that a weak thunk from sized to unsized deallocation could be emitted to avoid breaking backwards compatibility with standard libraries not providing sized deallocation. However, this approach and other variations don't work in practice. With the weak function approach, the thunk has to have default visibility in order to ensure that it is overridden by other DSOs providing sized deallocation. Weak, default visibility symbols are particularly expensive on MachO, so John McCall was considering disabling this feature by default on Darwin. It also changes behavior ELF linking behavior, causing certain otherwise unreferenced object files from an archive to be pulled into the link. Our second approach was to use an extern_weak function declaration and do an inline conditional branch at the deletion call site. This doesn't work because extern_weak only works on MachO if you have some archive providing the default value of the extern_weak symbol. Arranging to provide such an archive has the same challenges as providing the symbol in the standard library. Not to mention that extern_weak doesn't really work on COFF. Reviewers: rsmith, rjmccall Differential Revision: http://reviews.llvm.org/D8467 llvm-svn: 232788
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp22
1 files changed, 0 insertions, 22 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index dabec15b784..9e80f0a0a1f 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -802,20 +802,6 @@ static void TryMarkNoThrow(llvm::Function *F) {
F->setDoesNotThrow();
}
-static void EmitSizedDeallocationFunction(CodeGenFunction &CGF,
- const FunctionDecl *UnsizedDealloc) {
- // This is a weak discardable definition of the sized deallocation function.
- CGF.CurFn->setLinkage(llvm::Function::LinkOnceAnyLinkage);
- if (CGF.CGM.supportsCOMDAT())
- CGF.CurFn->setComdat(
- CGF.CGM.getModule().getOrInsertComdat(CGF.CurFn->getName()));
-
- // Call the unsized deallocation function and forward the first argument
- // unchanged.
- llvm::Constant *Unsized = CGF.CGM.GetAddrOfFunction(UnsizedDealloc);
- CGF.Builder.CreateCall(Unsized, &*CGF.CurFn->arg_begin());
-}
-
void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
const CGFunctionInfo &FnInfo) {
const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
@@ -891,14 +877,6 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
emitImplicitAssignmentOperatorBody(Args);
} else if (Stmt *Body = FD->getBody()) {
EmitFunctionBody(Args, Body);
- } else if (FunctionDecl *UnsizedDealloc =
- FD->getCorrespondingUnsizedGlobalDeallocationFunction()) {
- // Global sized deallocation functions get an implicit weak definition if
- // they don't have an explicit definition, if allowed.
- assert(getLangOpts().DefineSizedDeallocation &&
- "Can't emit unallowed definition.");
- EmitSizedDeallocationFunction(*this, UnsizedDealloc);
-
} else
llvm_unreachable("no definition for emitted function");
OpenPOWER on IntegriCloud