[llvm-dev] Can a Constant have more than one use?

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 9 11:43:04 PDT 2017


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.

We rely on this to check equality of constants by doing only a pointer
compare in many places.

~Craig

On Wed, Aug 9, 2017 at 11:38 AM, John Criswell via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> On 8/9/17 1:23 PM, Siddharth Bhat via llvm-dev wrote:
>
> As the question asks. IIRC, I have only seen constants use to:
>
> 1. setup globals
> 2. as "constant parameters" to instructions.
>
> 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?
>
>
> 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.
>
> Regards,
>
> John Criswell
>
>
> Thanks,
> Siddharth
> --
> Sending this from my phone, please excuse any typos!
>
>
> _______________________________________________
> LLVM Developers mailing listllvm-dev at lists.llvm.orghttp://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
>
> --
> John Criswell
> Assistant Professor
> Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170809/a41e28b4/attachment-0001.html>


More information about the llvm-dev mailing list