Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / Linux / local_alias.cpp
bloba8b3d75e375bfd32f2197c71673fca2c074603ce
1 // Test that mixing instrumented and non-instrumented code doesn't lead to crash.
2 // Build two modules (one is instrumented, another is not) that have globals
3 // with same names. Check, that ASan doesn't crash with CHECK failure or
4 // false positive global-buffer-overflow due to sanitized library poisons
5 // globals from non-sanitized one.
6 //
7 // RUN: %clangxx_asan -DBUILD_INSTRUMENTED_DSO=1 -fPIC -shared -mllvm -asan-use-private-alias %s -o %dynamiclib1
8 // RUN: %clangxx -DBUILD_UNINSTRUMENTED_DSO=1 -fPIC -shared %s -o %dynamiclib2
9 // RUN: %clangxx %s -c -mllvm -asan-use-private-alias -o %t.o
10 // RUN: %clangxx_asan %t.o %ld_flags_rpath_exe2 %ld_flags_rpath_exe1 -o %t-EXE
11 // RUN: %run %t-EXE
13 #if defined (BUILD_INSTRUMENTED_DSO)
14 long h = 15;
15 long f = 4;
16 long foo(long *p) {
17 return *p;
19 #elif defined (BUILD_UNINSTRUMENTED_DSO)
20 long foo(long *);
21 long h = 12;
22 long i = 13;
23 long f = 5;
25 int bar() {
26 if (foo(&f) != 5 || foo(&h) != 12 || foo(&i) != 13)
27 return 1;
28 return 0;
30 #else
31 extern int bar();
33 int main() {
34 return bar();
36 #endif