This code:
GlobalVariable *virtAddr = new GlobalVariable(...);
virtAddr = builder.CreateCall(mmap,putsArgs,"mmap");
does not "convert a CallInst to a GlobalVariable" any more than this code will "convert 3 to 4":
int x = 3;
x = 4;
In other words, it's a regular C++ assignment into a variable. In your case the value and the variable do not even have compatible types so you're getting a standard C++ type error.
So how do you assign the results of a function call (or any other value) into a global variable? Well, global variables always represent a pointer to some memory location; so if you want to store anything there, you need to use a StoreInst
, giving it the global variable as the address and the call instruction as the value to store.