about summary refs log tree commit diff homepage
path: root/test
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2019-03-16 23:27:20 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2019-03-18 20:29:35 +0000
commit842966d5f2921e807ddc348505ee710eba3ad86d (patch)
tree847f010a578f011e787def078dc33a6f42e48aad /test
parent33394de6b4f14a7677e7c470be80929c1192b98e (diff)
downloadklee-842966d5f2921e807ddc348505ee710eba3ad86d.tar.gz
Disable optimisation for functions that contain KLEE calls
Compilers are allowed to hoist function calls and do GVE.
This is currently done even without `--optimization` enabled.

This is unfortunate in the context of KLEE function calls that might
depend on specific code position without direct control flow
dependencies. In such cases, function calls can be hoisted.

To circumvent this, disallow to optimise functions that contain such
calls by default. This might reduce optimisation for some functions
containing such function calls but still allows it for all others.

This patch adds an additional pass, that detects all functions starting with a
prefix `klee_` and disable optimisations for functions containing such
calls.

This is enabled by default but can be disabled by
`--klee-call-optimisation=false`.
Diffstat (limited to 'test')
-rw-r--r--test/Feature/srem.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/test/Feature/srem.c b/test/Feature/srem.c
index 57bea901..1303ac63 100644
--- a/test/Feature/srem.c
+++ b/test/Feature/srem.c
@@ -1,6 +1,9 @@
 // RUN: %clang %s -emit-llvm -g %O0opt -c -o %t.bc
 // RUN: rm -rf %t.klee-out
-// RUN: %klee --output-dir=%t.klee-out -use-cex-cache=1 %t.bc 2>&1 | FileCheck %s
+// RUN: %klee --output-dir=%t.klee-out --klee-call-optimisation=false %t.bc 2>&1 | FileCheck %s
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out --klee-call-optimisation=false --optimize %t.bc 2>&1 | FileCheck %s
+
 #include <stdio.h>
 #include <assert.h>