Add a command line option 'fregister_global_dtors_with_atexit' to
authorAkira Hatanaka <ahatanaka@apple.com>
Tue, 17 Apr 2018 18:41:52 +0000 (18:41 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Tue, 17 Apr 2018 18:41:52 +0000 (18:41 +0000)
commit617e26152dea71efc44a45f5ae034f15c92767f0
tree964d175311edcbfe8346fb800a3fec1461726064
parent8fa100dfe3c36687f3ab09804657fdf4fa946bdf
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
13 files changed:
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/CodeGenOptions.def
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/constructor-attribute.c
clang/test/Driver/cxa-atexit.cpp
clang/test/Driver/rewrite-legacy-objc.m
clang/test/Driver/rewrite-objc.m