cloud9_root/src/cloud9/lib/Module/ProgramDependenceGraph.cpp
// Remove one star from the value being dereferenced (from) and create an
// assignment from-->to.
//
// Control dependencies will be created to the derefenced values from the
// passed instruction
Remove one star from the value being dereferenced (from) and create an
assignment from-->to.

Control dependencies will be created to the derefenced values from the
passed instruction
Remove one star from the value being dereferenced ( from ) and create an assignment from -- > to . Control dependencies will be created to the derefenced values from the passed instruction
std::string PDG::createStore(Value *to, Value *from, Instruction *i) {
	assert(to && "NULL passed");
	assert(from && "NULL passed");
	assert(to->getType() && "to value with NULL type");
	assert(to->getType()->isPointerTy() && "to value that is not a pointer");
	assert(to->getType()->isPointerTy() && "to value that is not a pointer");
	std::string toStr = IDMap.saveAndGetID(to);
	std::string fromStr = IDMap.saveAndGetID(from);
	 The dereferenced string is not actually a value in the program. It is
	 simply a temporary node in the graph which is used to hook up with
	 subsequent loads. It is not stored in the ValToStrDB and thus will not be
	 found in the module's metadata. After the analysis is done, it can be
	 discarded.
	std::string derefTo = ValToStrDB::rmStar(toStr);
	 When we dereference a pointer we create a new (and unique) node in the
	 program dependence graph. We need to connect it with its parent (e.g.,
	 the store, which is a dereferenced pointer assignment, should have the
	 same control dependencies as its parent).
	std::string ret = createAssign(derefTo, toStr);
	 The instruction performing the store is data dependent on the pointer
	 being stored into
	assert(i && "NULL Passed");
	std::string ret = createAssign(IDMap.saveAndGetID(i), toStr);
	 The instruction performing the store is data dependent on the value
	 being stored
	ret += "\n";
	ret += createAssign(IDMap.saveAndGetID(i), fromStr);
	 The dereferenced pointer is data dependent on the store instruction.
	 This a forward slice on the store will touch everything which touched
	 the pointer moditified by the store
	ret += "\n";
	ret += createAssign(derefTo, IDMap.saveAndGetID(i));
	 Assigning to the derefenced pointer the value operand
	 Since the store instruction is already data dependent on fromStr the
	 dereferenced pointer does not need to be.
	ret += "\n";
	ret += createAssign(derefTo, fromStr);
	return ret;
}
std :: string PDG :: createStore ( Value * to , Value * from , Instruction * i ) { assert ( to && " " ) ; assert ( from && " " ) ; assert ( to -> getType ( ) && " " ) ; assert ( to -> getType ( ) -> isPointerTy ( ) && " " ) ; assert ( to -> getType ( ) -> isPointerTy ( ) && " " ) ; std :: string toStr = IDMap . saveAndGetID ( to ) ; std :: string fromStr = IDMap . saveAndGetID ( from ) ; std :: string derefTo = ValToStrDB :: rmStar ( toStr ) ; std :: string ret = createAssign ( IDMap . saveAndGetID ( i ) , toStr ) ; ret += " \n " ; ret += createAssign ( IDMap . saveAndGetID ( i ) , fromStr ) ; ret += " \n " ; ret += createAssign ( derefTo , IDMap . saveAndGetID ( i ) ) ; return ret ; }
Remove one star from the value being dereferenced (from) and create an
assignment from-->to.
Remove one star from the value being dereferenced ( from ) and create an assignment from -- > to .
// Currently only support storing to some types: // Storing an {instruction, function argument, global variable} in a // {global, instruction} // Get the ID of the dereferenced form of the from pointer // Remove one star from the value being stored(i.e., the pointer operand). // This represents it being dereferenced once. // // The dereferenced string is not actually a value in the program. It is // simply a temporary node in the graph which is used to hook up with // subsequent loads. It is not stored in the ValToStrDB and thus will not be // found in the module's metadata. After the analysis is done, it can be // discarded. // When we dereference a pointer we create a new (and unique) node in the // program dependence graph. We need to connect it with its parent (e.g., // the store, which is a dereferenced pointer assignment, should have the // same control dependencies as its parent). //std::string ret = createAssign(derefTo, toStr); // The instruction performing the store is data dependent on the pointer // being stored into //	assert(i && "NULL Passed"); // The instruction performing the store is data dependent on the value // being stored // The dereferenced pointer is data dependent on the store instruction. // This a forward slice on the store will touch everything which touched // the pointer moditified by the store // Assigning to the derefenced pointer the value operand // Since the store instruction is already data dependent on fromStr the // dereferenced pointer does not need to be. //ret += "\n"; //ret += createAssign(derefTo, fromStr);