From 710b2fbe5445a843bba2f0edca038b3c9252bc64 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Sun, 12 Feb 2012 22:54:22 +0000 Subject: Teach KLEE how to handle new ConstantDataSequential type. Patch by arrowdodger! git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@150355 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Core/Executor.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib/Core/Executor.cpp') diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index e13cebb9..d9983493 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -399,6 +399,15 @@ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os, for (unsigned i=0, e=cs->getNumOperands(); i != e; ++i) initializeGlobalObject(state, os, cs->getOperand(i), offset + sl->getElementOffset(i)); +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1) + } else if (const ConstantDataSequential *cds = + dyn_cast(c)) { + unsigned elementSize = + targetData->getTypeStoreSize(cds->getElementType()); + for (unsigned i=0, e=cds->getNumElements(); i != e; ++i) + initializeGlobalObject(state, os, cds->getElementAsConstant(i), + offset + i*elementSize); +#endif } else { unsigned StoreBits = targetData->getTypeStoreSizeInBits(c->getType()); ref C = evalConstant(c); @@ -945,6 +954,17 @@ ref Executor::evalConstant(const Constant *c) { return Expr::createPointer(0); } else if (isa(c) || isa(c)) { return ConstantExpr::create(0, getWidthForLLVMType(c->getType())); +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1) + } else if (const ConstantDataSequential *cds = + dyn_cast(c)) { + std::vector > kids; + for (unsigned i = 0, e = cds->getNumElements(); i != e; ++i) { + ref kid = evalConstant(cds->getElementAsConstant(i)); + kids.push_back(kid); + } + ref res = ConcatExpr::createN(kids.size(), kids.data()); + return cast(res); +#endif } else if (const ConstantStruct *cs = dyn_cast(c)) { const StructLayout *sl = kmodule->targetData->getStructLayout(cs->getType()); llvm::SmallVector, 4> kids; -- cgit 1.4.1