cloud9_root/src/cloud9/lib/Module/ProgramDependenceGraph.cpp
// Create a data dependence from-->to assuming that the values come from a
// load. This will dereference the from value.
//
// The passed instruction is the instruction actually performing the load.
// The dereferenced values will be come control dependent on the passed
// instruction. This ensures that the dereferenced values keep their parents
// control dependencies
Create a data dependence from-->to assuming that the values come from a
load. This will dereference the from value.

The passed instruction is the instruction actually performing the load.
The dereferenced values will be come control dependent on the passed
instruction. This ensures that the dereferenced values keep their parents
control dependencies
Create a data dependence from -- > to assuming that the values come from a load . This will dereference the from value . The passed instruction is the instruction actually performing the load . The dereferenced values will be come control dependent on the passed instruction . This ensures that the dereferenced values keep their parents control dependencies
std::string PDG::createLoad(Value *to, Value *from, Instruction *i) {
	assert(to && "NULL Passed");
	assert(from && "NULL Passed");
	assert(from->getType() && "from value with NULL type");
	assert(from->getType()->isPointerTy() && "from value that is not a pointer");
	assert(from->getType()->isPointerTy() && "from value that is not a pointer");
	if (ConstantExpr *ce = (dyn_cast<ConstantExpr>(from))) {
		from = ValToStrDB::getConstExprUse(ce);
	}
	if (!(isa<Instruction>(from) || isa<Argument>(from) || isa<GlobalVariable>(from))) {
		llvm_unreachable("unhandled load type (see above)");
	}
	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 derefFrom = ValToStrDB::rmStar(fromStr);
	 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(derefFrom, fromStr);
	 The instruction performing the load is data dependent on the pointer
	 being loaded
	assert(i && "NULL Passed");
	std::string ret = createAssign(IDMap.saveAndGetID(i), fromStr);
	 create a oontrol dependency to the dereferenced value from the
	 instruction
	 Markus: This control dependency is not necessary. The load is simply a
	 flow of data not control
	ret += "\n";
	ret += createCDep(derefFrom, IDMap.saveAndGetID(i));
	ret += "\n";
	ret += createAssign(toStr, derefFrom);
	return ret;
}
std :: string PDG :: createLoad ( Value * to , Value * from , Instruction * i ) { assert ( to && " " ) ; assert ( from && " " ) ; assert ( from -> getType ( ) && " " ) ; assert ( from -> getType ( ) -> isPointerTy ( ) && " " ) ; assert ( from -> getType ( ) -> isPointerTy ( ) && " " ) ; if ( ConstantExpr * ce = ( dyn_cast < ConstantExpr > ( from ) ) ) { from = ValToStrDB :: getConstExprUse ( ce ) ; } if ( ! ( isa < Instruction > ( from ) || isa < Argument > ( from ) || isa < GlobalVariable > ( from ) ) ) { llvm_unreachable ( " " ) ; } std :: string toStr = IDMap . saveAndGetID ( to ) ; std :: string fromStr = IDMap . saveAndGetID ( from ) ; std :: string derefFrom = ValToStrDB :: rmStar ( fromStr ) ; assert ( i && " " ) ; std :: string ret = createAssign ( IDMap . saveAndGetID ( i ) , fromStr ) ; ret += " \n " ; ret += createAssign ( toStr , derefFrom ) ; return ret ; }
Create a data dependence from-->to assuming that the values come from a
load.
Create a data dependence from -- > to assuming that the values come from a load .
// Get the ID of the dereferenced form of the from pointer // Remove one star from the to. This represents it being dereferenced // once. That is, in a store instruction, the pointer operand is dereferenced // and then assigned. // // 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(derefFrom, fromStr); // The instruction performing the load is data dependent on the pointer // being loaded // create a oontrol dependency to the dereferenced value from the // instruction // Markus: This control dependency is not necessary. The load is simply a // flow of data not control //ret += "\n"; //ret += createCDep(derefFrom, IDMap.saveAndGetID(i));