From 5e3d7f3a3aa8d11b67e74de0c3d9187c323cbff2 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 15 Jun 2009 13:37:39 +0200 Subject: PR10274 Fix exelib -O3 testcase. The testcase now uses noinline, an empty asm statement and a volatile variable to prevent the function getting inlined, being totally unrolled or the recursive call being replaced with an inner-iteration. This does defeat part of the testcase though, which was testing unwinding through an optimized recursive function. But it seems the best we can do. * testsuite/systemtap.exelib/exelib.exp: Add -O3 to the mix. * testsuite/systemtap.exelib/uprobes_exe.c: Use volatile bar and mark main_func noinline. * testsuite/systemtap.exelib/uprobes_lib.c: Use volatile foo and mark lib_func noinline. --- testsuite/systemtap.exelib/uprobes_lib.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'testsuite/systemtap.exelib/uprobes_lib.c') diff --git a/testsuite/systemtap.exelib/uprobes_lib.c b/testsuite/systemtap.exelib/uprobes_lib.c index 25297b6b..072a1d61 100644 --- a/testsuite/systemtap.exelib/uprobes_lib.c +++ b/testsuite/systemtap.exelib/uprobes_lib.c @@ -7,15 +7,24 @@ * later version. */ -void +// volatile static variable to prevent folding of lib_func +static volatile int foo; + +// Marked noinline and has an empty asm statement to prevent inlining +// or optimizing away totally. +int +__attribute__((noinline)) lib_func (int bar) { - if (bar > 1) - lib_func (bar - 1); + asm (""); + if (bar - foo > 0) + foo = lib_func (bar - foo); + return foo; } void lib_main () { - lib_func (3); + foo = 1; + foo = lib_func (3); } -- cgit