#include
#include “llvm/IR/InstrTypes.h”
#include “llvm/IR/Instruction.h”
Copyright By PowCoder代写 加微信 powcoder
#include “SymbolicInterpreter.h”
extern SymbolicInterpreter SI;
z3::expr eval(z3::expr &E) {
if (E.kind() == Z3_NUMERAL_AST) {
MemoryTy Mem = SI.getMemory();
Address Register(E);
if (Mem.find(Register) != Mem.end()) {
return Mem.at(Register);
std::cout << "Warning: Cannot find register " << Register << " in memory "
<< std::endl;
* @brief Symbolically evaluate Alloca
* @param R RegisterID
* @param Ptr Address
extern "C" void __DSE_Alloca__(int R, int *Ptr) {
MemoryTy &Mem = SI.getMemory();
Address Register(R);
z3::expr SE = SI.getContext().int_val((uintptr_t)Ptr);
Mem.insert(std::make_pair(Register, SE));
* @brief Symbolically evaluate Store
* @param X Address
extern "C" void __DSE_Store__(int *X) {
MemoryTy &Mem = SI.getMemory();
Address Addr(X);
z3::expr SE = eval(SI.getStack().top());
SI.getStack().pop();
Mem.erase(Addr);
Mem.insert(std::make_pair(Addr, SE));
* @brief Symbolically evaluate Load
* TODO: Implement this.
* @param Y Address of destination
* @param X Address of Load source
extern "C" void __DSE_Load__(int Y, int *X) {
* @brief Symbolically evaluate Comparisions
* TODO: Implement this.
* @param R Address of Comparision result
* @param Op Operator Kind
extern "C" void __DSE_ICmp__(int R, int Op) {
* @brief Symbolically evaluate Binary Operation.
* TODO: Implement this.
* @param R Address of Binary Operation result.
* @param Op Operator Kind
extern "C" void __DSE_BinOp__(int R, int Op) {
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com