[PATCH] D83974: [AIX] report_fatal_error on `-fregister_global_dtors_with_atexit` for static init
Xiangling Liao via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 16 11:40:51 PDT 2020
Xiangling_L created this revision.
Xiangling_L added reviewers: jasonliu, hubert.reinterpretcast, yusra.syeda.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
On AIX, the semantic of global_dtors contains `__sterm` functions associated with C++ cleanup actions and user-declared `__attribute__((__destructor__))` functions. We will never register `__sterm` with `atexit()`, so currently `-fregister_global_dtors_with_atexit` does not work well on AIX. 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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83974
Files:
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
clang/test/Driver/cxa-atexit.cpp
Index: clang/test/Driver/cxa-atexit.cpp
===================================================================
--- clang/test/Driver/cxa-atexit.cpp
+++ 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
Index: clang/test/CodeGenCXX/aix-sinit-register-global-dtors-with-atexit.cpp
===================================================================
--- /dev/null
+++ 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 on AIX yet
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1209,6 +1209,9 @@
/// when the module is unloaded.
void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) {
if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) {
+ if (getContext().getTargetInfo().getTriple().isOSAIX())
+ llvm::report_fatal_error(
+ "register global dtors with atexit() is not supported on AIX yet");
DtorsUsingAtExit[Priority].push_back(Dtor);
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83974.278558.patch
Type: text/x-patch
Size: 3283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200716/ff9d97ab/attachment-0001.bin>
More information about the cfe-commits
mailing list