From 479f8068a769885e0fb50bf37f886ef839e63609 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Wed, 14 Dec 2016 18:12:10 +0000 Subject: Teach KLEE to respect the requested memory alignment of globals and stack variables when possible. Previously an alignment 8 was always used which did not faithfully emulate what was either explicitly requested in the LLVM IR or what the default alignment was for the target. --- test/regression/2016-12-14-alloc-alignment.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/regression/2016-12-14-alloc-alignment.c (limited to 'test/regression/2016-12-14-alloc-alignment.c') diff --git a/test/regression/2016-12-14-alloc-alignment.c b/test/regression/2016-12-14-alloc-alignment.c new file mode 100644 index 00000000..db66d191 --- /dev/null +++ b/test/regression/2016-12-14-alloc-alignment.c @@ -0,0 +1,21 @@ +// RUN: %llvmgcc %s -Wall -emit-llvm -g -O0 -c -o %t.bc +// RUN: rm -rf %t.klee-out +// RUN: %klee --output-dir=%t.klee-out --exit-on-error %t.bc +#include +#include +#include +#include + +// Global should be aligned on a 128-byte boundary +int foo __attribute__((aligned(128))); + +int main() { + int bar __attribute__((aligned(256))); + + // Check alignment of global + assert(((size_t)&foo) % 128 == 0); + + // Check alignment of local + assert(((size_t)&bar) % 256 == 0); + return 0; +} -- cgit 1.4.1