demo.cpp
//#define INEV_BB
/* Get instruction id.
 */
define INEV_BB
Get instruction id.
define INEV_BB Get instruction id .
unsigned Support::getInstructionID(Instruction * I) 
{
	MDNode * Node = I->getMetadata("ins_id");
	if(!Node)
	{
		return -1;
	}
	assert(Node->getNumOperands() == 1);
	const Metadata * MD = Node->getOperand(0);
	if(auto *MDV = dyn_cast<ValueAsMetadata>(MD))
	{
		Value * V = MDV->getValue();
		ConstantInt * CI = dyn_cast<ConstantInt>(V);
		assert(CI);
		return CI->getZExtValue();
	}
	return -1;
}
unsigned Support :: getInstructionID ( Instruction * I ) { MDNode * Node = I -> getMetadata ( " " ) ; if ( ! Node ) { return -1 ; } assert ( Node -> getNumOperands ( ) == 1 ) ; const Metadata * MD = Node -> getOperand ( 0 ) ; if ( auto * MDV = dyn_cast < ValueAsMetadata > ( MD ) ) { Value * V = MDV -> getValue ( ) ; ConstantInt * CI = dyn_cast < ConstantInt > ( V ) ; assert ( CI ) ; return CI -> getZExtValue ( ) ; } return -1 ; }
define INEV_BB
Get instruction id.
define INEV_BB Get instruction id .