The SWL is a map where i have store address as key and the constant as its corresponding value. However when i check this store being used in load i try to replace the uses of the store instruction with the constant. Doing so does not replace the instruction. There is no change in the byte code after running this pass.
std::map<Value*,Value*> SWL;
for (User::op_iterator OI = I.op_begin(); OI != I.op_end(); ++OI)
{
Value *v = *OI;
std::map<Value*,Value*> :: iterator re = SWL.find(v);
if(re != SWL.end() && isa<LoadInst>(&I))
{
I.replaceAllUsesWith(re->second);
bRet = true;
}
}