1 #include <stdio.h> 2 #include "../memcheck.h" 3 #define INLINE inline __attribute__((always_inline)) 4 fun_d(int argd)5INLINE int fun_d(int argd) { 6 static int locd = 0; 7 if (argd > 0) 8 locd += argd; 9 return locd; 10 } 11 fun_c(int argc)12INLINE int fun_c(int argc) { 13 static int locc = 0; 14 locc += argc; 15 return fun_d(locc); 16 } 17 fun_b(int argb)18INLINE int fun_b(int argb) { 19 static int locb = 0; 20 locb += argb; 21 return fun_c(locb); 22 } 23 fun_a(int arga)24INLINE int fun_a(int arga) { 25 static int loca = 0; 26 loca += arga; 27 return fun_b(loca); 28 } 29 30 __attribute__((noinline)) fun_noninline_m(int argm)31static int fun_noninline_m(int argm) 32 { 33 return fun_d(argm); 34 } 35 36 __attribute__((noinline)) fun_noninline_o(int argo)37static int fun_noninline_o(int argo) 38 { 39 static int loco = 0; 40 if (argo > 0) 41 loco += argo; 42 return loco; 43 } 44 fun_f(int argf)45INLINE int fun_f(int argf) { 46 static int locf = 0; 47 locf += argf; 48 return fun_noninline_o(locf); 49 } 50 fun_e(int arge)51INLINE int fun_e(int arge) { 52 static int loce = 0; 53 loce += arge; 54 return fun_f(loce); 55 } 56 57 __attribute__((noinline)) fun_noninline_n(int argn)58static int fun_noninline_n(int argn) 59 { 60 return fun_e(argn); 61 } 62 63 main()64int main() { 65 int result; 66 result = fun_a(result); 67 VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result)); 68 result += fun_noninline_m(result); 69 VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result)); 70 result += fun_d(result); 71 VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result)); 72 result += fun_noninline_n(result); 73 return 0; 74 } 75 76