Author: Xiangling Liao Date: 2020-07-17T16:14:49-04:00 New Revision: ec6ada62643cf7cded8160e04cce163323112ade
URL: https://github.com/llvm/llvm-project/commit/ec6ada62643cf7cded8160e04cce163323112ade DIFF: https://github.com/llvm/llvm-project/commit/ec6ada62643cf7cded8160e04cce163323112ade.diff LOG: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init On AIX, the semantic of global_dtors contains __sterm functions associated with C++ cleanup actions and user-declared __attribute__((destructor)) functions. We should never merely register __sterm with atexit(), so currently -fregister_global_dtors_with_atexit does not work well on AIX: It would cause finalization actions to not occur when unloading shared libraries. We need to figure out a way to handle that when we start supporting user-declared __attribute__((destructor)) functions. Currently we report_fatal_error on this option temporarily. Differential Revision: https://reviews.llvm.org/D83974 Added: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp Modified: clang/lib/CodeGen/CodeGenModule.cpp clang/test/Driver/cxa-atexit.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4ae8ce7e5ccf..4c792520b5f3 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1209,6 +1209,9 @@ void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority, /// when the module is unloaded. void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) { if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) { + if (getCXXABI().useSinitAndSterm()) + llvm::report_fatal_error( + "register global dtors with atexit() is not supported yet"); DtorsUsingAtExit[Priority].push_back(Dtor); return; } diff --git a/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp b/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp new file mode 100644 index 000000000000..4cec83d461ad --- /dev/null +++ b/clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp @@ -0,0 +1,14 @@ +// RUN: not %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \ +// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \ +// RUN: FileCheck %s + +// RUN: not %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \ +// RUN: -fregister-global-dtors-with-atexit < %s 2>&1 | \ +// RUN: FileCheck %s + +struct T { + T(); + ~T(); +} t; + +// CHECK: error in backend: register global dtors with atexit() is not supported yet diff --git a/clang/test/Driver/cxa-atexit.cpp b/clang/test/Driver/cxa-atexit.cpp index e81af6cd5963..537a11a35f51 100644 --- a/clang/test/Driver/cxa-atexit.cpp +++ b/clang/test/Driver/cxa-atexit.cpp @@ -36,6 +36,7 @@ // RUN: FileCheck --check-prefix=WITHATEXIT %s // RUN: %clang -target x86_64-apple-darwin -c -mkernel -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s + // RUN: %clang -target x86_64-pc-linux-gnu -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s // RUN: %clang -target x86_64-pc-linux-gnu -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \ @@ -43,5 +44,18 @@ // RUN: %clang -target x86_64-pc-linux-gnu -c -### %s 2>&1 | \ // RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHATEXIT %s +// RUN: %clang -target powerpc-ibm-aix-xcoff -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -fregister-global-dtors-with-atexit -fno-register-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -fno-register-global-dtors-with-atexit -fregister-global-dtors-with-atexit -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHATEXIT %s +// RUN: %clang -target powerpc64-ibm-aix-xcoff -c -### %s 2>&1 | \ +// RUN: FileCheck --check-prefix=WITHOUTATEXIT %s + // WITHATEXIT: -fregister-global-dtors-with-atexit // WITHOUTATEXIT-NOT: -fregister-global-dtors-with-atexit _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits