2018-07-12 04:26:20 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-msvc -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-MS -check-prefix CHECK-MS-DYNAMIC
|
|
|
|
// RUN: %clang_cc1 -triple i686-windows-msvc -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-MS -check-prefix CHECK-MS-STATIC
|
2016-12-15 14:59:05 +08:00
|
|
|
|
2019-12-12 18:26:54 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-NODECL-IA -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-NODECL-IA -check-prefix CHECK-IA-STATIC-CXA-ATEXIT
|
2019-12-12 18:26:54 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -DIMPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IMPORT-IA -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -DIMPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IMPORT-IA -check-prefix CHECK-IA-STATIC-CXA-ATEXIT
|
2019-12-12 18:26:54 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -DEXPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -DEXPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-IA-STATIC-CXA-ATEXIT
|
2019-12-12 18:26:54 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -DDECL -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-DECL-IA -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -DDECL -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-DECL-IA -check-prefix CHECK-IA-STATIC-CXA-ATEXIT
|
2016-12-15 14:59:05 +08:00
|
|
|
// %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IA-ATEXIT
|
|
|
|
// %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IA-ATEXIT
|
|
|
|
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
|
|
|
|
// RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
|
2019-04-30 07:05:47 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
|
2018-07-12 04:26:20 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
|
2016-12-15 14:59:05 +08:00
|
|
|
|
|
|
|
#if defined(IMPORT_DECLARATIONS)
|
|
|
|
namespace __cxxabiv1 {
|
|
|
|
extern "C" {
|
|
|
|
__declspec(dllimport) void __cxa_guard_acquire(unsigned long long *);
|
|
|
|
__declspec(dllimport) unsigned char *__cxa_allocate_exception(unsigned long);
|
|
|
|
}
|
|
|
|
extern "C" __declspec(dllimport) void __cxa_guard_release(unsigned long long *);
|
|
|
|
}
|
|
|
|
namespace std {
|
|
|
|
__declspec(dllimport) __declspec(noreturn) void terminate();
|
|
|
|
}
|
|
|
|
#elif defined(EXPORT_DECLARATIONS)
|
|
|
|
namespace __cxxabiv1 {
|
|
|
|
extern "C" {
|
|
|
|
__declspec(dllexport) void __cxa_guard_acquire(unsigned long long *);
|
|
|
|
__declspec(dllexport) unsigned char *__cxa_allocate_exception(unsigned long);
|
|
|
|
}
|
|
|
|
extern "C" void __declspec(dllexport) __cxa_guard_release(unsigned long long *);
|
|
|
|
}
|
|
|
|
namespace std {
|
|
|
|
__declspec(dllexport) __declspec(noreturn) void terminate();
|
|
|
|
}
|
|
|
|
#elif defined(DECL)
|
|
|
|
namespace __cxxabiv1 {
|
|
|
|
extern "C" unsigned char *__cxa_allocate_exception(unsigned long);
|
|
|
|
}
|
|
|
|
namespace std {
|
|
|
|
__declspec(noreturn) void terminate();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
namespace std {
|
|
|
|
__declspec(noreturn) void terminate();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct s {
|
|
|
|
s() = default;
|
|
|
|
s(unsigned char) { throw 0; }
|
|
|
|
int m() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct t {
|
|
|
|
~t();
|
|
|
|
int m() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct u {
|
|
|
|
~u();
|
|
|
|
};
|
|
|
|
|
|
|
|
s o;
|
|
|
|
thread_local t t;
|
|
|
|
u v;
|
|
|
|
__declspec(thread) s q;
|
|
|
|
|
|
|
|
void __declspec(noinline) f() {
|
|
|
|
throw 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void g();
|
|
|
|
void __declspec(noinline) h() {
|
|
|
|
try {
|
|
|
|
g();
|
|
|
|
} catch (const int &) {
|
|
|
|
return;
|
|
|
|
} catch (...) {
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void i() {
|
|
|
|
s r(static_cast<unsigned char>('\t'));
|
|
|
|
}
|
|
|
|
|
|
|
|
int j() {
|
|
|
|
static thread_local struct t v;
|
|
|
|
static struct t *w = new struct t;
|
|
|
|
return w->m() ? v.m() : w->m();
|
|
|
|
}
|
|
|
|
|
|
|
|
void k() noexcept {
|
|
|
|
g();
|
|
|
|
}
|
|
|
|
|
|
|
|
void l() {
|
|
|
|
std::terminate();
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-MS-DAG: @_Init_thread_epoch = external thread_local global i32
|
2018-03-21 04:27:30 +08:00
|
|
|
// CHECK-MS-DAG: declare dso_local i32 @__tlregdtor(void ()*)
|
|
|
|
// CHECK-MS-DAG: declare dso_local i32 @atexit(void ()*)
|
2019-04-30 07:05:47 +08:00
|
|
|
// CHECK-MS-DYNAMIC-DAG: declare {{.*}} void @_CxxThrowException
|
2016-12-15 14:59:05 +08:00
|
|
|
// CHECK-MS-STATIC-DAG: declare {{.*}} void @_CxxThrowException
|
[clang] Annotating C++'s `operator new` with more attributes
Summary:
Right now we annotate C++'s `operator new` with `noalias` attribute,
which very much is healthy for optimizations.
However as per [[ http://eel.is/c++draft/basic.stc.dynamic.allocation | `[basic.stc.dynamic.allocation]` ]],
there are more promises on global `operator new`, namely:
* non-`std::nothrow_t` `operator new` *never* returns `nullptr`
* If `std::align_val_t align` parameter is taken, the pointer will also be `align`-aligned
* ~~global `operator new`-returned pointer is `__STDCPP_DEFAULT_NEW_ALIGNMENT__`-aligned ~~ It's more caveated than that.
Supplying this information may not cause immediate landslide effects
on any specific benchmarks, but it for sure will be healthy for optimizer
in the sense that the IR will better reflect the guarantees provided in the source code.
The caveat is `-fno-assume-sane-operator-new`, which currently prevents emitting `noalias`
attribute, and is automatically passed by Sanitizers ([[ https://bugs.llvm.org/show_bug.cgi?id=16386 | PR16386 ]]) - should it also cover these attributes?
The problem is that the flag is back-end-specific, as seen in `test/Modules/explicit-build-flags.cpp`.
But while it is okay to add `noalias` metadata in backend, we really should be adding at least
the alignment metadata to the AST, since that allows us to perform sema checks on it.
Reviewers: erichkeane, rjmccall, jdoerfert, eugenis, rsmith
Reviewed By: rsmith
Subscribers: xbolva00, jrtc27, atanasyan, nlopes, cfe-commits
Tags: #llvm, #clang
Differential Revision: https://reviews.llvm.org/D73380
2020-02-26 06:37:17 +08:00
|
|
|
// CHECK-MS-DAG: declare dso_local nonnull i8* @"??2@YAPAXI@Z"
|
2018-03-21 04:27:30 +08:00
|
|
|
// CHECK-MS-DAG: declare dso_local void @_Init_thread_header(i32*)
|
|
|
|
// CHECK-MS-DAG: declare dso_local void @_Init_thread_footer(i32*)
|
2016-12-15 14:59:05 +08:00
|
|
|
|
2018-03-08 07:18:06 +08:00
|
|
|
// CHECK-IA-DAG: @_ZTH1t = dso_local alias void (), void ()* @__tls_init
|
2018-03-21 04:27:30 +08:00
|
|
|
// CHECK-IA-DAG: declare dso_local i32 @__gxx_personality_v0(...)
|
2019-08-03 22:28:34 +08:00
|
|
|
// CHECK-IA-DAG: define linkonce_odr hidden void @__clang_call_terminate(i8* %0)
|
2016-12-15 14:59:05 +08:00
|
|
|
|
|
|
|
// CHECK-DYNAMIC-IA-DAG: declare dllimport i32 @__cxa_thread_atexit(void (i8*)*, i8*, i8*)
|
|
|
|
// CHECK-DYNAMIC-IA-DAG: declare dllimport i32 @__cxa_atexit(void (i8*)*, i8*, i8*)
|
|
|
|
// CHECK-DYNAMIC-IA-DECL-DAG: declare i8* @__cxa_allocate_exception(i32)
|
|
|
|
// CHECK-DYNAMIC-IA-NODECL-DAG: declare dllimport i8* @__cxa_allocate_exception(i32)
|
|
|
|
// CHECK-DYNAMIC-IA-IMPORT-DAG: declare dllimport i8* @__cxa_allocate_exception(i32)
|
|
|
|
// CHECK-DYNAMIC-IA-EXPORT-DAG: declare dllimport i8* @__cxa_allocate_exception(i32)
|
|
|
|
// CHECK-DYNAMIC-IA-DAG: declare dllimport void @__cxa_throw(i8*, i8*, i8*)
|
|
|
|
// CHECK-DYNAMIC-DECL-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(i64*)
|
|
|
|
// CHECK-DYNAMIC-NODECL-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(i64*)
|
|
|
|
// CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(i64*)
|
|
|
|
// CHECK-DYNAMIC-EXPORT-IA-DAG: declare dllexport i32 @__cxa_guard_acquire(i64*)
|
[clang] Annotating C++'s `operator new` with more attributes
Summary:
Right now we annotate C++'s `operator new` with `noalias` attribute,
which very much is healthy for optimizations.
However as per [[ http://eel.is/c++draft/basic.stc.dynamic.allocation | `[basic.stc.dynamic.allocation]` ]],
there are more promises on global `operator new`, namely:
* non-`std::nothrow_t` `operator new` *never* returns `nullptr`
* If `std::align_val_t align` parameter is taken, the pointer will also be `align`-aligned
* ~~global `operator new`-returned pointer is `__STDCPP_DEFAULT_NEW_ALIGNMENT__`-aligned ~~ It's more caveated than that.
Supplying this information may not cause immediate landslide effects
on any specific benchmarks, but it for sure will be healthy for optimizer
in the sense that the IR will better reflect the guarantees provided in the source code.
The caveat is `-fno-assume-sane-operator-new`, which currently prevents emitting `noalias`
attribute, and is automatically passed by Sanitizers ([[ https://bugs.llvm.org/show_bug.cgi?id=16386 | PR16386 ]]) - should it also cover these attributes?
The problem is that the flag is back-end-specific, as seen in `test/Modules/explicit-build-flags.cpp`.
But while it is okay to add `noalias` metadata in backend, we really should be adding at least
the alignment metadata to the AST, since that allows us to perform sema checks on it.
Reviewers: erichkeane, rjmccall, jdoerfert, eugenis, rsmith
Reviewed By: rsmith
Subscribers: xbolva00, jrtc27, atanasyan, nlopes, cfe-commits
Tags: #llvm, #clang
Differential Revision: https://reviews.llvm.org/D73380
2020-02-26 06:37:17 +08:00
|
|
|
// CHECK-IA-DAG: declare dso_local nonnull i8* @_Znwj(i32)
|
2016-12-15 14:59:05 +08:00
|
|
|
// CHECK-DYNAMIC-DECL-IA-DAG: declare dllimport void @__cxa_guard_release(i64*)
|
|
|
|
// CHECK-DYNAMIC-NODECL-IA-DAG: declare dllimport void @__cxa_guard_release(i64*)
|
|
|
|
// CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport void @__cxa_guard_release(i64*)
|
|
|
|
// CHECK-DYNAMIC-EXPORT-IA-DAG: declare dllimport void @__cxa_guard_release(i64*)
|
2019-12-12 19:46:17 +08:00
|
|
|
// CHECK-DYANMIC-IA-DAG: declare dllimport void @_ZSt9terminatev()
|
2018-03-21 04:27:30 +08:00
|
|
|
// CHECK-DYNAMIC-NODECL-IA-DAG: declare dso_local void @_ZSt9terminatev()
|
2016-12-15 14:59:05 +08:00
|
|
|
// CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport void @_ZSt9terminatev()
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-DYNAMIC-EXPORT-IA-DAG: declare dso_local dllexport void @_ZSt9terminatev()
|
2016-12-15 14:59:05 +08:00
|
|
|
|
2018-03-21 04:27:30 +08:00
|
|
|
// CHECK-STATIC-IA-DAG: declare dso_local i32 @__cxa_thread_atexit(void (i8*)*, i8*, i8*)
|
|
|
|
// CHECK-STATIC-IA-DAG: declare dso_local i32 @__cxa_atexit(void (i8*)*, i8*, i8*)
|
|
|
|
// CHECK-STATIC-IA-DAG: declare dso_local i8* @__cxa_allocate_exception(i32)
|
|
|
|
// CHECK-STATIC-IA-DAG: declare dso_local void @__cxa_throw(i8*, i8*, i8*)
|
|
|
|
// CHECK-STATIC-DECL-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*)
|
|
|
|
// CHECK-STATIC-NODECL-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*)
|
|
|
|
// CHECK-STATIC-IMPORT-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*)
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-STATIC-EXPORT-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*)
|
[clang] Annotating C++'s `operator new` with more attributes
Summary:
Right now we annotate C++'s `operator new` with `noalias` attribute,
which very much is healthy for optimizations.
However as per [[ http://eel.is/c++draft/basic.stc.dynamic.allocation | `[basic.stc.dynamic.allocation]` ]],
there are more promises on global `operator new`, namely:
* non-`std::nothrow_t` `operator new` *never* returns `nullptr`
* If `std::align_val_t align` parameter is taken, the pointer will also be `align`-aligned
* ~~global `operator new`-returned pointer is `__STDCPP_DEFAULT_NEW_ALIGNMENT__`-aligned ~~ It's more caveated than that.
Supplying this information may not cause immediate landslide effects
on any specific benchmarks, but it for sure will be healthy for optimizer
in the sense that the IR will better reflect the guarantees provided in the source code.
The caveat is `-fno-assume-sane-operator-new`, which currently prevents emitting `noalias`
attribute, and is automatically passed by Sanitizers ([[ https://bugs.llvm.org/show_bug.cgi?id=16386 | PR16386 ]]) - should it also cover these attributes?
The problem is that the flag is back-end-specific, as seen in `test/Modules/explicit-build-flags.cpp`.
But while it is okay to add `noalias` metadata in backend, we really should be adding at least
the alignment metadata to the AST, since that allows us to perform sema checks on it.
Reviewers: erichkeane, rjmccall, jdoerfert, eugenis, rsmith
Reviewed By: rsmith
Subscribers: xbolva00, jrtc27, atanasyan, nlopes, cfe-commits
Tags: #llvm, #clang
Differential Revision: https://reviews.llvm.org/D73380
2020-02-26 06:37:17 +08:00
|
|
|
// CHECK-IA-DAG: declare dso_local nonnull i8* @_Znwj(i32)
|
2018-03-21 04:27:30 +08:00
|
|
|
// CHECK-STATIC-DECL-IA-DAG: declare dso_local void @__cxa_guard_release(i64*)
|
|
|
|
// CHECK-STATIC-NODECL-IA-DAG: declare dso_local void @__cxa_guard_release(i64*)
|
|
|
|
// CHECK-STATIC-IMPORT-IA-DAG: declare dso_local void @__cxa_guard_release(i64*)
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-STATIC-EXPORT-IA-DAG: declare dso_local void @__cxa_guard_release(i64*)
|
2018-03-21 04:27:30 +08:00
|
|
|
// CHECK-STATIC-IA-DAG: declare dso_local void @_ZSt9terminatev()
|
|
|
|
// CHECK-STATIC-NODECL-IA-DAG: declare dso_local void @_ZSt9terminatev()
|
|
|
|
// CHECK-STATIC-IMPORT-IA-DAG: declare dso_local void @_ZSt9terminatev()
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-STATIC-EXPORT-IA-DAG: declare dso_local dllexport void @_ZSt9terminatev()
|