From f8e621c4845664a9ad32b5f4b8fe3db2b134dac3 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 5 Aug 2010 17:53:23 +0000 Subject: Store CallInst and InvokeInst operands in a fixed order: function, arg0, arg1, ... git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@110352 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Core/Executor.cpp | 12 ++---------- lib/Module/KModule.cpp | 52 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 26 deletions(-) (limited to 'lib') diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 5632b208..b0af78a1 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -1499,15 +1499,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { case Instruction::Invoke: case Instruction::Call: { - CallSite cs; - unsigned argStart; - if (i->getOpcode()==Instruction::Call) { - cs = CallSite(cast(i)); - argStart = 1; - } else { - cs = CallSite(cast(i)); - argStart = 3; - } + CallSite cs(i); unsigned numArgs = cs.arg_size(); Function *f = getCalledFunction(cs, state); @@ -1521,7 +1513,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { arguments.reserve(numArgs); for (unsigned j=0; j ®isterMap, + KModule *km, + KInstruction *ki) { + if (Instruction *inst = dyn_cast(v)) { + return registerMap[inst]; + } else if (Argument *a = dyn_cast(v)) { + return a->getArgNo(); + } else if (isa(v) || isa(v) || + isa(v)) { + return -1; + } else { + assert(isa(v)); + Constant *c = cast(v); + return -(km->getConstantID(c, ki) + 2); + } +} + KFunction::KFunction(llvm::Function *_function, KModule *km) : function(_function), @@ -524,24 +543,25 @@ KFunction::KFunction(llvm::Function *_function, ki = new KInstruction(); break; } - unsigned numOperands = it->getNumOperands(); ki->inst = it; - ki->operands = new int[numOperands]; ki->dest = registerMap[it]; - for (unsigned j=0; jgetOperand(j); - - if (Instruction *inst = dyn_cast(v)) { - ki->operands[j] = registerMap[inst]; - } else if (Argument *a = dyn_cast(v)) { - ki->operands[j] = a->getArgNo(); - } else if (isa(v) || isa(v) || - isa(v)) { - ki->operands[j] = -1; - } else { - assert(isa(v)); - Constant *c = cast(v); - ki->operands[j] = -(km->getConstantID(c, ki) + 2); + + if (isa(it) || isa(it)) { + CallSite cs(it); + unsigned numArgs = cs.arg_size(); + ki->operands = new int[numArgs+1]; + ki->operands[0] = getOperandNum(cs.getCalledValue(), registerMap, km, + ki); + for (unsigned j=0; joperands[j+1] = getOperandNum(v, registerMap, km, ki); + } + } else { + unsigned numOperands = it->getNumOperands(); + ki->operands = new int[numOperands]; + for (unsigned j=0; jgetOperand(j); + ki->operands[j] = getOperandNum(v, registerMap, km, ki); } } -- cgit 1.4.1