title: Get pointer to llvm::Value previously allocated for CreateLoad function
body: <p>I'm new to llvm and I'm writing a small llvm IR Builder.
  I use the IRBuilder and all these Create* functions to generate my IR.
  What I'm trying to do is to create a <strong>load</strong> instruction which create a new SSA local variable with value of a previously allocated <strong>llvm::Value</strong>.</p>
  
  <p>What I expected to have : </p>
  
  <pre><code>%2 = load i32* %1
  </code></pre>
  
  <p>With <strong>%2</strong> results of load instruction and <strong>%1</strong> my previously allocated Value (CreateAlloca)</p>
  
  <p>Here is what I tried :</p>
  
  <pre><code>// Get Ptr from Val
  Value* ptr = ConstantExpr::getIntToPtr((Constant*)loc[n],PointerType::getUnqual(builder-&gt;getInt32Ty()));
  
  // Générate load instruction with the new Ptr
  builder-&gt;CreateLoad(ptr);
  </code></pre>
  
  <p>And here is what I have :</p>
  
  <pre><code>%2 = load i32* null
  </code></pre>
  
  <p><strong>loc</strong> is an array which contains all my llvm::Value*</p>
  
  <p>Can you please tell me what I'm doing wrong ? Or maybe if I'm on a bad way ?
  Thanks.</p>