cloud9_root/src/cloud9/lib/Core/Executor_CSCA.cpp
//
// generate set equality constraints for <symbolic, constant> address pairs
generate set equality constraints for  address pairs
generate set equality constraints for address pairs
ref<Expr> Executor::createCacheSetCompareConstraintSC(ref<Expr> &addr1, ref<Expr> &addr2) {
	unsigned set;
	klee::ref<Expr> set_addr;
	std::pair<klee::ref<Expr>, klee::ref<Expr> > setPair(addr1, addr2);
	if (setPairCache.count(setPair)) {
		return setPairCache[setPair];
	}
	if (addr1->getKind() == Expr::Constant) {
		ConstantExpr* CE = dyn_cast<ConstantExpr>(addr1);
		uint64_t addr_mem = CE->getZExtValue();
		set = getCacheSet(addr_mem);
		if (setCache.count(addr2)) set_addr = setCache[addr2];
		else {
			set_addr = getCacheSet(addr2);
			setCache[addr2] = set_addr;
		}
	} else {
		ConstantExpr* CE = dyn_cast<ConstantExpr>(addr2);
		uint64_t addr_mem = CE->getZExtValue();
		set = getCacheSet(addr_mem);
		if (setCache.count(addr1)) set_addr = setCache[addr1];
		else {
			set_addr = getCacheSet(addr1);
			setCache[addr1] = set_addr;
		}
	}
	setPairCache[setPair] = EqExpr::create(set_addr, ConstantExpr::alloc(set, set_addr->getWidth()));
	return setPairCache[setPair];
}
ref < Expr > Executor :: createCacheSetCompareConstraintSC ( ref < Expr > & addr1 , ref < Expr > & addr2 ) { unsigned set ; klee :: ref < Expr > set_addr ; std :: pair < klee :: ref < Expr > , klee :: ref < Expr > > setPair ( addr1 , addr2 ) ; if ( setPairCache . count ( setPair ) ) { return setPairCache [ setPair ] ; } if ( addr1 -> getKind ( ) == Expr :: Constant ) { ConstantExpr * CE = dyn_cast < ConstantExpr > ( addr1 ) ; uint64_t addr_mem = CE -> getZExtValue ( ) ; set = getCacheSet ( addr_mem ) ; if ( setCache . count ( addr2 ) ) set_addr = setCache [ addr2 ] ; else { set_addr = getCacheSet ( addr2 ) ; setCache [ addr2 ] = set_addr ; } } else { ConstantExpr * CE = dyn_cast < ConstantExpr > ( addr2 ) ; uint64_t addr_mem = CE -> getZExtValue ( ) ; set = getCacheSet ( addr_mem ) ; if ( setCache . count ( addr1 ) ) set_addr = setCache [ addr1 ] ; else { set_addr = getCacheSet ( addr1 ) ; setCache [ addr1 ] = set_addr ; } } setPairCache [ setPair ] = EqExpr :: create ( set_addr , ConstantExpr :: alloc ( set , set_addr -> getWidth ( ) ) ) ; return setPairCache [ setPair ] ; }
generate set equality constraints for <symbolic, constant> address pairs
generate set equality constraints for <symbolic constant > address pairs
// try to look up in cache // either addr1 or addr2 is constant expr