compile time and runtime in LLVM

Hello everybody,

I have some issues in the communication between the compile and runtime.

What I am doing is to locate an "add" instruction in the IR and then, after the "add" I insert some new instructions. Then I save the instructions in a vector (in the example the the "add", the "or" and the "xor"). The instrumentation part is working so far.

In the runtime, I want to select every specific time one instruction from the vector I created in the compile time before, during the instrumentation. Specifically, I want to select the original "add", or the "or" or the "xor" and pass it in the "store" instruction. However, I cannot pass the new value form the runtime to select which instruction from the vector to be stored. I try to do this in through the counterStop function.

call void @counterStop()
%8 = load i32* %x, align 4,
%9 = add nsw i32 %8, 2
%10 = shl i32 1, 2
%11 = or i32 %8, %10
%15 = shl i32 1, 2
%16 = xor i32 %8, %15
store i32 %9, i32* %x, align 4

Any ideas how to change the value in the vector through the runtime?