[PATCH] D63283: PR42182: Allow thread-local to use __cxa_thread_atexit when -fno-use-cxx-atexit is used
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 10:08:08 PDT 2019
erichkeane created this revision.
erichkeane added reviewers: jyu2, rnk, ahatanak, rjmccall, jyknight.
Herald added a subscriber: dexonsmith.
Herald added a project: clang.
This matches the GCC behavior, __cxa_thread_atexit should be permissible
even though cxa_atexit is disabled.
Repository:
rC Clang
https://reviews.llvm.org/D63283
Files:
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGenCXX/cxx11-thread-local.cpp
Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===================================================================
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -4,6 +4,12 @@
// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -O2 -disable-llvm-passes -o - -triple x86_64-linux-gnu | FileCheck --check-prefix=CHECK --check-prefix=LINUX --check-prefix=CHECK-OPT %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -femulated-tls -emit-llvm %s -o - \
+// RUN: -triple x86_64-linux-gnu 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=LINUX %s
+// RUN: %clang_cc1 -std=c++11 -fno-use-cxa-atexit -emit-llvm %s -o - -triple x86_64-apple-darwin12 | FileCheck --check-prefix=CHECK --check-prefix=DARWIN %s
+
int f();
int g();
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2270,6 +2270,8 @@
static void emitGlobalDtorWithCXAAtExit(CodeGenFunction &CGF,
llvm::FunctionCallee dtor,
llvm::Constant *addr, bool TLS) {
+ assert((TLS || CGF.getTypes().getCodeGenOpts().CXAAtExit) &&
+ "__cxa_atexit is disabled");
const char *Name = "__cxa_atexit";
if (TLS) {
const llvm::Triple &T = CGF.getTarget().getTriple();
@@ -2364,12 +2366,9 @@
return;
// Use __cxa_atexit if available.
- if (CGM.getCodeGenOpts().CXAAtExit)
+ if (CGM.getCodeGenOpts().CXAAtExit || D.getTLSKind())
return emitGlobalDtorWithCXAAtExit(CGF, dtor, addr, D.getTLSKind());
- if (D.getTLSKind())
- CGM.ErrorUnsupported(&D, "non-trivial TLS destruction");
-
// In Apple kexts, we want to add a global destructor entry.
// FIXME: shouldn't this be guarded by some variable?
if (CGM.getLangOpts().AppleKext) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63283.204571.patch
Type: text/x-patch
Size: 2323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190613/1aae4a42/attachment.bin>
More information about the cfe-commits
mailing list