klee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KModule.cpp
Go to the documentation of this file.
1 //===-- KModule.cpp -------------------------------------------------------===//
2 //
3 // The KLEE Symbolic Virtual Machine
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // FIXME: This does not belong here.
11 #include "../Core/Common.h"
12 
14 
15 #include "Passes.h"
16 
17 #include "klee/Config/Version.h"
18 #include "klee/Interpreter.h"
23 
24 #include "llvm/Bitcode/ReaderWriter.h"
25 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
26 #include "llvm/IR/Instructions.h"
27 #include "llvm/IR/LLVMContext.h"
28 #include "llvm/IR/Module.h"
29 #include "llvm/IR/ValueSymbolTable.h"
30 #include "llvm/IR/DataLayout.h"
31 #else
32 #include "llvm/Instructions.h"
33 #include "llvm/LLVMContext.h"
34 #include "llvm/Module.h"
35 #include "llvm/ValueSymbolTable.h"
36 #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
37 #include "llvm/Target/TargetData.h"
38 #else
39 #include "llvm/DataLayout.h"
40 #endif
41 
42 #endif
43 
44 #include "llvm/PassManager.h"
45 #include "llvm/Support/CallSite.h"
46 #include "llvm/Support/CommandLine.h"
47 #include "llvm/Support/raw_ostream.h"
48 #include "llvm/Support/raw_os_ostream.h"
49 #include "llvm/Support/Path.h"
50 #include "llvm/Transforms/Scalar.h"
51 
52 #include <llvm/Transforms/Utils/Cloning.h>
53 #include <llvm/Support/InstIterator.h>
54 #include <llvm/Support/Debug.h>
55 
56 #include <sstream>
57 
58 using namespace llvm;
59 using namespace klee;
60 
61 namespace {
63  eSwitchTypeSimple,
64  eSwitchTypeLLVM,
65  eSwitchTypeInternal
66  };
67 
68  cl::list<std::string>
69  MergeAtExit("merge-at-exit");
70 
71  cl::opt<bool>
72  NoTruncateSourceLines("no-truncate-source-lines",
73  cl::desc("Don't truncate long lines in the output source"));
74 
75  cl::opt<bool>
76  OutputSource("output-source",
77  cl::desc("Write the assembly for the final transformed source"),
78  cl::init(true));
79 
80  cl::opt<bool>
81  OutputModule("output-module",
82  cl::desc("Write the bitcode for the final transformed module"),
83  cl::init(false));
84 
85  cl::opt<SwitchImplType>
86  SwitchType("switch-type", cl::desc("Select the implementation of switch"),
87  cl::values(clEnumValN(eSwitchTypeSimple, "simple",
88  "lower to ordered branches"),
89  clEnumValN(eSwitchTypeLLVM, "llvm",
90  "lower using LLVM"),
91  clEnumValN(eSwitchTypeInternal, "internal",
92  "execute switch internally"),
93  clEnumValEnd),
94  cl::init(eSwitchTypeInternal));
95 
96  cl::opt<bool>
97  DebugPrintEscapingFunctions("debug-print-escaping-functions",
98  cl::desc("Print functions whose address is taken."));
99 }
100 
101 KModule::KModule(Module *_module)
102  : module(_module),
103 #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
104  targetData(new TargetData(module)),
105 #else
106  targetData(new DataLayout(module)),
107 #endif
108  kleeMergeFn(0),
109  infos(0),
110  constantTable(0) {
111 }
112 
114  delete[] constantTable;
115  delete infos;
116 
117  for (std::vector<KFunction*>::iterator it = functions.begin(),
118  ie = functions.end(); it != ie; ++it)
119  delete *it;
120 
121  for (std::map<llvm::Constant*, KConstant*>::iterator it=constantMap.begin(),
122  itE=constantMap.end(); it!=itE;++it)
123  delete it->second;
124 
125  delete targetData;
126  delete module;
127 }
128 
129 /***/
130 
131 namespace llvm {
132 extern void Optimize(Module*);
133 }
134 
135 // what a hack
136 static Function *getStubFunctionForCtorList(Module *m,
137  GlobalVariable *gv,
138  std::string name) {
139  assert(!gv->isDeclaration() && !gv->hasInternalLinkage() &&
140  "do not support old LLVM style constructor/destructor lists");
141 
142  std::vector<LLVM_TYPE_Q Type*> nullary;
143 
144  Function *fn = Function::Create(FunctionType::get(Type::getVoidTy(getGlobalContext()),
145  nullary, false),
146  GlobalVariable::InternalLinkage,
147  name,
148  m);
149  BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entry", fn);
150 
151  // From lli:
152  // Should be an array of '{ int, void ()* }' structs. The first value is
153  // the init priority, which we ignore.
154  ConstantArray *arr = dyn_cast<ConstantArray>(gv->getInitializer());
155  if (arr) {
156  for (unsigned i=0; i<arr->getNumOperands(); i++) {
157  ConstantStruct *cs = cast<ConstantStruct>(arr->getOperand(i));
158  assert(cs->getNumOperands()==2 && "unexpected element in ctor initializer list");
159 
160  Constant *fp = cs->getOperand(1);
161  if (!fp->isNullValue()) {
162  if (llvm::ConstantExpr *ce = dyn_cast<llvm::ConstantExpr>(fp))
163  fp = ce->getOperand(0);
164 
165  if (Function *f = dyn_cast<Function>(fp)) {
166  CallInst::Create(f, "", bb);
167  } else {
168  assert(0 && "unable to get function pointer from ctor initializer list");
169  }
170  }
171  }
172  }
173 
174  ReturnInst::Create(getGlobalContext(), bb);
175 
176  return fn;
177 }
178 
180  GlobalVariable *ctors = m->getNamedGlobal("llvm.global_ctors");
181  GlobalVariable *dtors = m->getNamedGlobal("llvm.global_dtors");
182 
183  if (ctors || dtors) {
184  Function *mainFn = m->getFunction("main");
185  if (!mainFn)
186  klee_error("Could not find main() function.");
187 
188  if (ctors)
189  CallInst::Create(getStubFunctionForCtorList(m, ctors, "klee.ctor_stub"),
190  "", mainFn->begin()->begin());
191  if (dtors) {
192  Function *dtorStub = getStubFunctionForCtorList(m, dtors, "klee.dtor_stub");
193  for (Function::iterator it = mainFn->begin(), ie = mainFn->end();
194  it != ie; ++it) {
195  if (isa<ReturnInst>(it->getTerminator()))
196  CallInst::Create(dtorStub, "", it->getTerminator());
197  }
198  }
199  }
200 }
201 
202 #if LLVM_VERSION_CODE < LLVM_VERSION(3, 3)
203 static void forceImport(Module *m, const char *name, LLVM_TYPE_Q Type *retType,
204  ...) {
205  // If module lacks an externally visible symbol for the name then we
206  // need to create one. We have to look in the symbol table because
207  // we want to check everything (global variables, functions, and
208  // aliases).
209 
210  Value *v = m->getValueSymbolTable().lookup(name);
211  GlobalValue *gv = dyn_cast_or_null<GlobalValue>(v);
212 
213  if (!gv || gv->hasInternalLinkage()) {
214  va_list ap;
215 
216  va_start(ap, retType);
217  std::vector<LLVM_TYPE_Q Type *> argTypes;
218  while (LLVM_TYPE_Q Type *t = va_arg(ap, LLVM_TYPE_Q Type*))
219  argTypes.push_back(t);
220  va_end(ap);
221 
222  m->getOrInsertFunction(name, FunctionType::get(retType, argTypes, false));
223  }
224 }
225 #endif
226 
232 static void inlineChecks(Module *module, const char * functionName) {
233  std::vector<CallSite> checkCalls;
234  Function* runtimeCheckCall = module->getFunction(functionName);
235  if (runtimeCheckCall == 0)
236  {
237  DEBUG( klee_warning("Failed to inline %s because no calls were made to it in module", functionName) );
238  return;
239  }
240 
241  for (Value::use_iterator i = runtimeCheckCall->use_begin(),
242  e = runtimeCheckCall->use_end(); i != e; ++i)
243  if (isa<InvokeInst>(*i) || isa<CallInst>(*i)) {
244  CallSite cs(*i);
245  if (!cs.getCalledFunction())
246  continue;
247  checkCalls.push_back(cs);
248  }
249 
250  unsigned int successCount=0;
251  unsigned int failCount=0;
252  InlineFunctionInfo IFI(0,0);
253  for ( std::vector<CallSite>::iterator ci = checkCalls.begin(),
254  cie = checkCalls.end();
255  ci != cie; ++ci)
256  {
257  // Try to inline the function
258  if (InlineFunction(*ci,IFI))
259  ++successCount;
260  else
261  {
262  ++failCount;
263  klee_warning("Failed to inline function %s", functionName);
264  }
265  }
266 
267  DEBUG( klee_message("Tried to inline calls to %s. %u successes, %u failures",functionName, successCount, failCount) );
268 }
269 
270 void KModule::addInternalFunction(const char* functionName){
271  Function* internalFunction = module->getFunction(functionName);
272  if (!internalFunction) {
273  DEBUG_WITH_TYPE("KModule", klee_warning(
274  "Failed to add internal function %s. Not found.", functionName));
275  return ;
276  }
277  DEBUG( klee_message("Added function %s.",functionName));
278  internalFunctions.insert(internalFunction);
279 }
280 
282  InterpreterHandler *ih) {
283  if (!MergeAtExit.empty()) {
284  Function *mergeFn = module->getFunction("klee_merge");
285  if (!mergeFn) {
286  LLVM_TYPE_Q llvm::FunctionType *Ty =
287  FunctionType::get(Type::getVoidTy(getGlobalContext()),
288  std::vector<LLVM_TYPE_Q Type*>(), false);
289  mergeFn = Function::Create(Ty, GlobalVariable::ExternalLinkage,
290  "klee_merge",
291  module);
292  }
293 
294  for (cl::list<std::string>::iterator it = MergeAtExit.begin(),
295  ie = MergeAtExit.end(); it != ie; ++it) {
296  std::string &name = *it;
297  Function *f = module->getFunction(name);
298  if (!f) {
299  klee_error("cannot insert merge-at-exit for: %s (cannot find)",
300  name.c_str());
301  } else if (f->isDeclaration()) {
302  klee_error("cannot insert merge-at-exit for: %s (external)",
303  name.c_str());
304  }
305 
306  BasicBlock *exit = BasicBlock::Create(getGlobalContext(), "exit", f);
307  PHINode *result = 0;
308  if (f->getReturnType() != Type::getVoidTy(getGlobalContext()))
309 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
310  result = PHINode::Create(f->getReturnType(), 0, "retval", exit);
311 #else
312  result = PHINode::Create(f->getReturnType(), "retval", exit);
313 #endif
314  CallInst::Create(mergeFn, "", exit);
315  ReturnInst::Create(getGlobalContext(), result, exit);
316 
317  llvm::errs() << "KLEE: adding klee_merge at exit of: " << name << "\n";
318  for (llvm::Function::iterator bbit = f->begin(), bbie = f->end();
319  bbit != bbie; ++bbit) {
320  if (&*bbit != exit) {
321  Instruction *i = bbit->getTerminator();
322  if (i->getOpcode()==Instruction::Ret) {
323  if (result) {
324  result->addIncoming(i->getOperand(0), bbit);
325  }
326  i->eraseFromParent();
327  BranchInst::Create(exit, bbit);
328  }
329  }
330  }
331  }
332  }
333 
334  // Inject checks prior to optimization... we also perform the
335  // invariant transformations that we will end up doing later so that
336  // optimize is seeing what is as close as possible to the final
337  // module.
338  PassManager pm;
339  pm.add(new RaiseAsmPass());
340  if (opts.CheckDivZero) pm.add(new DivCheckPass());
341  if (opts.CheckOvershift) pm.add(new OvershiftCheckPass());
342  // FIXME: This false here is to work around a bug in
343  // IntrinsicLowering which caches values which may eventually be
344  // deleted (via RAUW). This can be removed once LLVM fixes this
345  // issue.
346  pm.add(new IntrinsicCleanerPass(*targetData, false));
347  pm.run(*module);
348 
349  if (opts.Optimize)
350  Optimize(module);
351 #if LLVM_VERSION_CODE < LLVM_VERSION(3, 3)
352  // Force importing functions required by intrinsic lowering. Kind of
353  // unfortunate clutter when we don't need them but we won't know
354  // that until after all linking and intrinsic lowering is
355  // done. After linking and passes we just try to manually trim these
356  // by name. We only add them if such a function doesn't exist to
357  // avoid creating stale uses.
358 
359  LLVM_TYPE_Q llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext());
360  forceImport(module, "memcpy", PointerType::getUnqual(i8Ty),
361  PointerType::getUnqual(i8Ty),
362  PointerType::getUnqual(i8Ty),
363  targetData->getIntPtrType(getGlobalContext()), (Type*) 0);
364  forceImport(module, "memmove", PointerType::getUnqual(i8Ty),
365  PointerType::getUnqual(i8Ty),
366  PointerType::getUnqual(i8Ty),
367  targetData->getIntPtrType(getGlobalContext()), (Type*) 0);
368  forceImport(module, "memset", PointerType::getUnqual(i8Ty),
369  PointerType::getUnqual(i8Ty),
370  Type::getInt32Ty(getGlobalContext()),
371  targetData->getIntPtrType(getGlobalContext()), (Type*) 0);
372 #endif
373  // FIXME: Missing force import for various math functions.
374 
375  // FIXME: Find a way that we can test programs without requiring
376  // this to be linked in, it makes low level debugging much more
377  // annoying.
378 
379  SmallString<128> LibPath(opts.LibraryDir);
380  llvm::sys::path::append(LibPath,
382  "kleeRuntimeIntrinsic.bc"
383 #else
384  "libkleeRuntimeIntrinsic.bca"
385 #endif
386  );
387  module = linkWithLibrary(module, LibPath.str());
388 
389  // Add internal functions which are not used to check if instructions
390  // have been already visited
391  if (opts.CheckDivZero)
392  addInternalFunction("klee_div_zero_check");
393  if (opts.CheckOvershift)
394  addInternalFunction("klee_overshift_check");
395 
396 
397  // Needs to happen after linking (since ctors/dtors can be modified)
398  // and optimization (since global optimization can rewrite lists).
400 
401  // Finally, run the passes that maintain invariants we expect during
402  // interpretation. We run the intrinsic cleaner just in case we
403  // linked in something with intrinsics but any external calls are
404  // going to be unresolved. We really need to handle the intrinsics
405  // directly I think?
406  PassManager pm3;
407  pm3.add(createCFGSimplificationPass());
408  switch(SwitchType) {
409  case eSwitchTypeInternal: break;
410  case eSwitchTypeSimple: pm3.add(new LowerSwitchPass()); break;
411  case eSwitchTypeLLVM: pm3.add(createLowerSwitchPass()); break;
412  default: klee_error("invalid --switch-type");
413  }
414  pm3.add(new IntrinsicCleanerPass(*targetData));
415  pm3.add(new PhiCleanerPass());
416  pm3.run(*module);
417 #if LLVM_VERSION_CODE < LLVM_VERSION(3, 3)
418  // For cleanliness see if we can discard any of the functions we
419  // forced to import.
420  Function *f;
421  f = module->getFunction("memcpy");
422  if (f && f->use_empty()) f->eraseFromParent();
423  f = module->getFunction("memmove");
424  if (f && f->use_empty()) f->eraseFromParent();
425  f = module->getFunction("memset");
426  if (f && f->use_empty()) f->eraseFromParent();
427 #endif
428 
429  // Write out the .ll assembly file. We truncate long lines to work
430  // around a kcachegrind parsing bug (it puts them on new lines), so
431  // that source browsing works.
432  if (OutputSource) {
433  llvm::raw_fd_ostream *os = ih->openOutputFile("assembly.ll");
434  assert(os && !os->has_error() && "unable to open source output");
435 
436  // We have an option for this in case the user wants a .ll they
437  // can compile.
438  if (NoTruncateSourceLines) {
439  *os << *module;
440  } else {
441  std::string string;
442  llvm::raw_string_ostream rss(string);
443  rss << *module;
444  rss.flush();
445  const char *position = string.c_str();
446 
447  for (;;) {
448  const char *end = index(position, '\n');
449  if (!end) {
450  *os << position;
451  break;
452  } else {
453  unsigned count = (end - position) + 1;
454  if (count<255) {
455  os->write(position, count);
456  } else {
457  os->write(position, 254);
458  *os << "\n";
459  }
460  position = end+1;
461  }
462  }
463  }
464  delete os;
465  }
466 
467  if (OutputModule) {
468  llvm::raw_fd_ostream *f = ih->openOutputFile("final.bc");
469  WriteBitcodeToFile(module, *f);
470  delete f;
471  }
472 
473  kleeMergeFn = module->getFunction("klee_merge");
474 
475  /* Build shadow structures */
476 
478 
479  for (Module::iterator it = module->begin(), ie = module->end();
480  it != ie; ++it) {
481  if (it->isDeclaration())
482  continue;
483 
484  KFunction *kf = new KFunction(it, this);
485 
486  for (unsigned i=0; i<kf->numInstructions; ++i) {
487  KInstruction *ki = kf->instructions[i];
488  ki->info = &infos->getInfo(ki->inst);
489  }
490 
491  functions.push_back(kf);
492  functionMap.insert(std::make_pair(it, kf));
493  }
494 
495  /* Compute various interesting properties */
496 
497  for (std::vector<KFunction*>::iterator it = functions.begin(),
498  ie = functions.end(); it != ie; ++it) {
499  KFunction *kf = *it;
500  if (functionEscapes(kf->function))
501  escapingFunctions.insert(kf->function);
502  }
503 
504  if (DebugPrintEscapingFunctions && !escapingFunctions.empty()) {
505  llvm::errs() << "KLEE: escaping functions: [";
506  for (std::set<Function*>::iterator it = escapingFunctions.begin(),
507  ie = escapingFunctions.end(); it != ie; ++it) {
508  llvm::errs() << (*it)->getName() << ", ";
509  }
510  llvm::errs() << "]\n";
511  }
512 }
513 
515  std::map<llvm::Constant*, KConstant*>::iterator it = constantMap.find(c);
516  if (it != constantMap.end())
517  return it->second;
518  return NULL;
519 }
520 
521 unsigned KModule::getConstantID(Constant *c, KInstruction* ki) {
522  KConstant *kc = getKConstant(c);
523  if (kc)
524  return kc->id;
525 
526  unsigned id = constants.size();
527  kc = new KConstant(c, id, ki);
528  constantMap.insert(std::make_pair(c, kc));
529  constants.push_back(c);
530  return id;
531 }
532 
533 /***/
534 
535 KConstant::KConstant(llvm::Constant* _ct, unsigned _id, KInstruction* _ki) {
536  ct = _ct;
537  id = _id;
538  ki = _ki;
539 }
540 
541 /***/
542 
543 static int getOperandNum(Value *v,
544  std::map<Instruction*, unsigned> &registerMap,
545  KModule *km,
546  KInstruction *ki) {
547  if (Instruction *inst = dyn_cast<Instruction>(v)) {
548  return registerMap[inst];
549  } else if (Argument *a = dyn_cast<Argument>(v)) {
550  return a->getArgNo();
551  } else if (isa<BasicBlock>(v) || isa<InlineAsm>(v) ||
552  isa<MDNode>(v)) {
553  return -1;
554  } else {
555  assert(isa<Constant>(v));
556  Constant *c = cast<Constant>(v);
557  return -(km->getConstantID(c, ki) + 2);
558  }
559 }
560 
561 KFunction::KFunction(llvm::Function *_function,
562  KModule *km)
563  : function(_function),
564  numArgs(function->arg_size()),
565  numInstructions(0),
566  trackCoverage(true) {
567  for (llvm::Function::iterator bbit = function->begin(),
568  bbie = function->end(); bbit != bbie; ++bbit) {
569  BasicBlock *bb = bbit;
571  numInstructions += bb->size();
572  }
573 
575 
576  std::map<Instruction*, unsigned> registerMap;
577 
578  // The first arg_size() registers are reserved for formals.
579  unsigned rnum = numArgs;
580  for (llvm::Function::iterator bbit = function->begin(),
581  bbie = function->end(); bbit != bbie; ++bbit) {
582  for (llvm::BasicBlock::iterator it = bbit->begin(), ie = bbit->end();
583  it != ie; ++it)
584  registerMap[it] = rnum++;
585  }
586  numRegisters = rnum;
587 
588  unsigned i = 0;
589  for (llvm::Function::iterator bbit = function->begin(),
590  bbie = function->end(); bbit != bbie; ++bbit) {
591  for (llvm::BasicBlock::iterator it = bbit->begin(), ie = bbit->end();
592  it != ie; ++it) {
593  KInstruction *ki;
594 
595  switch(it->getOpcode()) {
596  case Instruction::GetElementPtr:
597  case Instruction::InsertValue:
598  case Instruction::ExtractValue:
599  ki = new KGEPInstruction(); break;
600  default:
601  ki = new KInstruction(); break;
602  }
603 
604  ki->inst = it;
605  ki->dest = registerMap[it];
606 
607  if (isa<CallInst>(it) || isa<InvokeInst>(it)) {
608  CallSite cs(it);
609  unsigned numArgs = cs.arg_size();
610  ki->operands = new int[numArgs+1];
611  ki->operands[0] = getOperandNum(cs.getCalledValue(), registerMap, km,
612  ki);
613  for (unsigned j=0; j<numArgs; j++) {
614  Value *v = cs.getArgument(j);
615  ki->operands[j+1] = getOperandNum(v, registerMap, km, ki);
616  }
617  } else {
618  unsigned numOperands = it->getNumOperands();
619  ki->operands = new int[numOperands];
620  for (unsigned j=0; j<numOperands; j++) {
621  Value *v = it->getOperand(j);
622  ki->operands[j] = getOperandNum(v, registerMap, km, ki);
623  }
624  }
625 
626  instructions[i++] = ki;
627  }
628  }
629 }
630 
632  for (unsigned i=0; i<numInstructions; ++i)
633  delete instructions[i];
634  delete[] instructions;
635 }
InstructionInfoTable * infos
Definition: KModule.h:105
Cell * constantTable
Definition: KModule.h:111
static Function * getStubFunctionForCtorList(Module *m, GlobalVariable *gv, std::string name)
Definition: KModule.cpp:136
void klee_error(const char *msg,...) __attribute__((format(printf
Definition: Common.cpp:73
const InstructionInfo * info
Definition: KInstruction.h:31
bool functionEscapes(const llvm::Function *f)
static int getOperandNum(Value *v, std::map< Instruction *, unsigned > &registerMap, KModule *km, KInstruction *ki)
Definition: KModule.cpp:543
virtual llvm::raw_fd_ostream * openOutputFile(const std::string &filename)=0
static void injectStaticConstructorsAndDestructors(Module *m)
Definition: KModule.cpp:179
llvm::Module * linkWithLibrary(llvm::Module *module, const std::string &libraryName)
Link a module with a specified bitcode archive.
std::set< llvm::Function * > escapingFunctions
Definition: KModule.h:103
unsigned dest
Destination register index.
Definition: KInstruction.h:39
std::map< llvm::BasicBlock *, unsigned > basicBlockEntry
Definition: KModule.h:51
unsigned numArgs
Definition: KModule.h:46
void void void klee_warning(const char *msg,...) __attribute__((format(printf
Definition: Common.cpp:81
KConstant * getKConstant(llvm::Constant *c)
Definition: KModule.cpp:514
std::set< const llvm::Function * > internalFunctions
Definition: KModule.h:114
KInstruction * ki
Definition: KModule.h:79
#define LLVM_VERSION_CODE
Definition: Version.h:16
#define LLVM_VERSION(major, minor)
Definition: Version.h:15
llvm::Function * kleeMergeFn
Definition: KModule.h:95
#define LLVM_TYPE_Q
Definition: Version.h:21
llvm::Function * function
Definition: KModule.h:44
void addInternalFunction(const char *functionName)
Definition: KModule.cpp:270
llvm::Instruction * inst
Definition: KInstruction.h:30
const InstructionInfo & getInfo(const llvm::Instruction *) const
KInstruction ** instructions
Definition: KModule.h:49
void Optimize(Module *)
Definition: Optimize.cpp:168
unsigned id
The constant ID.
Definition: KModule.h:75
void klee_message(const char *msg,...) __attribute__((format(printf
Definition: Common.cpp:58
std::vector< KFunction * > functions
Definition: KModule.h:98
unsigned numInstructions
Definition: KModule.h:48
KFunction(const KFunction &)
std::vector< llvm::Constant * > constants
Definition: KModule.h:107
unsigned getConstantID(llvm::Constant *c, KInstruction *ki)
Return an id for the given constant, creating a new one if necessary.
Definition: KModule.cpp:521
unsigned numRegisters
Definition: KModule.h:46
llvm::Constant * ct
Actual LLVM constant this represents.
Definition: KModule.h:72
void prepare(const Interpreter::ModuleOptions &opts, InterpreterHandler *ihandler)
Initialize local data structures.
Definition: KModule.cpp:281
KConstant(llvm::Constant *, unsigned, KInstruction *)
Definition: KModule.cpp:535
llvm::Module * module
Definition: KModule.h:87
SwitchImplType
Definition: KModule.cpp:62
std::map< llvm::Constant *, KConstant * > constantMap
Definition: KModule.h:108
std::map< llvm::Function *, KFunction * > functionMap
Definition: KModule.h:99
llvm::TargetData * targetData
Definition: KModule.h:89
static void inlineChecks(Module *module, const char *functionName)
Definition: KModule.cpp:232