I want to add an instruction at the end of the base unit to increase the value of GlobalVariable (using the C ++ LLVM library). I'm new to LLVM, can I do it directly or does it take to load a global variable, increment it by the desired value and write it back to the global variable?
Even if I load a variable (using the LoadInst constructor), how does the Add command know where the variable is?
For example, look at this IR ocde:
%cell_index = load i32* %cell_index_ptr
%new_cell_index = add i32 1, %cell_index
add command knows which variable to work for (cell_index). But since I will create a load instruction from C ++, I do not know where the variable will be created.
source
share