Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Linux / preinit_test.cpp
blobf8c2b6bf52f1df60bfd4e509af89e685deec0822
1 // RUN: %clangxx -DFUNC=zzzz %s -shared -o %dynamiclib -fPIC
2 // RUN: %clangxx_asan -DFUNC=main %s -o %t %ld_flags_rpath_exe
3 // RUN: %run %t
5 // GNU driver doesn't handle .so files properly.
6 // REQUIRES: Clang
8 // This test ensures that we call __asan_init early enough.
9 // We build a shared library w/o asan instrumentation
10 // and the binary with asan instrumentation.
11 // Both files include the same header (emulated by -DFUNC here)
12 // with C++ template magic which runs global initializer at library load time.
13 // The function get() is instrumented with asan, but called
14 // before the usual constructors are run.
15 // So, we must make sure that __asan_init is executed even earlier.
17 // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56393
19 struct A {
20 int foo() const { return 0; }
22 A get () { return A(); }
23 template <class> struct O {
24 static A const e;
26 template <class T> A const O <T>::e = get();
27 int FUNC() {
28 return O<int>::e.foo();