title: LLVM: Replacing all instances of an address with a constant
body: <p>I'm trying to replace all instances of an address with a constant.</p>
  
  <p>I'm getting &amp; testing the address of store with the following (i is an instruction)</p>
  
  <pre><code>//already know it's a store instruction at this point
  llvm::Value *addy = i-&gt;getOperand(0);
  if(llvm::ConstantInt* c = dyn_cast&lt;llvm:::ConstantInt&gt;(addy)){
     //replace all uses of the address with the constant
     //operand(1) will be the address the const would be stored at
     i-&gt;getOperand(1)-&gt;replaceAllUsesWith(c);
  }
  </code></pre>
  
  <p>I'd think this would work, but I'm getting the error that</p>
  
  <pre><code>"Assertion: New-&gt;getType()== getType() &amp;&amp; replaceAllUses of value with new value of different type!" failed
  </code></pre>
  
  <p>and I'm not sure why...my understanding of replaceAllUses is that it would replace usage of address (i->getOperand(1) with the constant?</p>