Add a command line option 'fregister_global_dtors_with_atexit' to
register destructor functions annotated with __attribute__((destructor))
using __cxa_atexit or atexit.
Register destructor functions annotated with __attribute__((destructor))
calling __cxa_atexit in a synthesized constructor function instead of
emitting references to the functions in a special section.
The primary reason for adding this option is that we are planning to
deprecate the __mod_term_funcs section on Darwin in the future. This
feature is enabled by default only on Darwin. Users who do not want this
can use command line option 'fno_register_global_dtors_with_atexit' to
disable it.
rdar://problem/33887655
Differential Revision: https://reviews.llvm.org/D45578
llvm-svn: 330199
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 5daa4e9..76af56b 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1336,6 +1336,12 @@
void checkAliases();
+ std::map<int, llvm::TinyPtrVector<llvm::Function *>> DtorsUsingAtExit;
+
+ /// Register functions annotated with __attribute__((destructor)) using
+ /// __cxa_atexit, if it is available, or atexit otherwise.
+ void registerGlobalDtorsWithAtExit();
+
void emitMultiVersionFunctions();
/// Emit any vtables which we deferred and still have a use for.