about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorCristian Cadar <cristic@cs.stanford.edu>2013-03-18 13:15:46 +0000
committerCristian Cadar <cristic@cs.stanford.edu>2013-03-18 13:15:46 +0000
commitc86988637c411a80556e26e07037dc6dcfade4d3 (patch)
tree60847b667a206383b58526991d8bbc688c74caf1
parent925bbe4d40cd1a40b95e6304e540223ba4680549 (diff)
downloadklee-c86988637c411a80556e26e07037dc6dcfade4d3.tar.gz
Patch and test case by Jiri Slaby to handle "initializing globals when
a global has an undef fill of holes inside structures."


git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@177285 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Core/Executor.cpp2
-rw-r--r--test/Concrete/GlobalUndef.ll15
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 3f90c426..fa5835d3 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -361,7 +361,7 @@ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os,
       initializeGlobalObject(state, os, cds->getElementAsConstant(i),
                              offset + i*elementSize);
 #endif
-  } else {
+  } else if (!isa<UndefValue>(c)) {
     unsigned StoreBits = targetData->getTypeStoreSizeInBits(c->getType());
     ref<ConstantExpr> C = evalConstant(c);
 
diff --git a/test/Concrete/GlobalUndef.ll b/test/Concrete/GlobalUndef.ll
new file mode 100644
index 00000000..c797ec81
--- /dev/null
+++ b/test/Concrete/GlobalUndef.ll
@@ -0,0 +1,15 @@
+; ModuleID = 'x.c'
+target datalayout =
+"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.anon = type { i8, [3 x i8] }
+
+@z = global %struct.anon { i8 1, [3 x i8] undef }, align 4
+
+define i32 @main() nounwind  {
+entry:
+  %retval = alloca i32, align 4
+  store i32 0, i32* %retval
+  ret i32 0
+}