Creating an object of value class

The constructor for Value class is declared as follows:

Value::Value	(	Type * 	Ty,
unsigned 	scid 
)		

What is scid here and what values should be passed to it ?

You never construct a Value directly, only one of its subclasses. So you almost certainly don’t need to worry about scid.

Instead, the ways you generally get Values are:

  1. Any Instruction is a Value (i.e. the value of its result). So using IRBuilder::CreateWhatever calls to create instructions and insert them into blocks is common.
  2. Constant is its own separate hierarchy, but also already a value, so you often see things like ConstantInt::get(...).
  3. Global variables and all functions are technically within Constant too, but they live inside a Module so you usually use Module::getOrInsertWhatever(...) to create these.
1 Like