<div dir="ltr">Every instance of a particular Constant type+value should use the same object. There are uniquing maps in the LLVMContext that are checked when any of the Constant*::get methods are called. If the constant has already been created that object will be reused.<div><br></div><div>We rely on this to check equality of constants by doing only a pointer compare in many places.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Wed, Aug 9, 2017 at 11:38 AM, John Criswell via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div class="m_6328358091205155845moz-cite-prefix">On 8/9/17 1:23 PM, Siddharth Bhat via
      llvm-dev wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">As the question asks. IIRC, I have only seen
        constants use to:
        <div><br>
        </div>
        <div>1. setup globals</div>
        <div>2. as "constant parameters" to instructions. </div>
        <div><br>
        </div>
        <div>In both these cases, from what I understand, they will have
          a single use. Is it possible to create a Constant with
          multiple use(r)s?</div>
      </div>
    </blockquote>
    <br>
    I am nearly positive that constants can be used more than once. 
    They subclass from Value.  I am sure that you can create a test
    program that uses the same constant value in different places and
    see if it generates one ConstantInt or multiple ConstantInts for the
    same constant integer.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Siddharth</div><span class="HOEnZb"><font color="#888888">
      </font></span></div><span class="HOEnZb"><font color="#888888">
      <div dir="ltr">-- <br>
      </div>
      <div class="m_6328358091205155845gmail_signature" data-smartmail="gmail_signature">
        <div dir="ltr">Sending this from my phone, please excuse any
          typos!</div>
      </div>
      <br>
      <fieldset class="m_6328358091205155845mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a class="m_6328358091205155845moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_6328358091205155845moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a>
</pre>
    </font></span></blockquote><span class="HOEnZb"><font color="#888888">
    <br>
    <p><br>
    </p>
    <pre class="m_6328358091205155845moz-signature" cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a class="m_6328358091205155845moz-txt-link-freetext" href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/<wbr>criswell</a></pre>
  </font></span></div>

<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>