Siddharth Bhat via llvm-dev
2017-Aug-09 18:23 UTC
[llvm-dev] Can a Constant have more than one use?
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? Thanks, Siddharth -- Sending this from my phone, please excuse any typos! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170809/c19fcc96/attachment.html>
John Criswell via llvm-dev
2017-Aug-09 18:38 UTC
[llvm-dev] Can a Constant have more than one use?
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 list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-- John Criswell Assistant Professor Department of Computer Science, University of Rochester http://www.cs.rochester.edu/u/criswell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170809/efe59056/attachment.html>
Craig Topper via llvm-dev
2017-Aug-09 18:43 UTC
[llvm-dev] Can a Constant have more than one use?
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>
Seemingly Similar Threads
- Inst->replaceAllUsesWith and uses in ConstantExpr
- Inst->replaceAllUsesWith and uses in ConstantExpr
- Debugging LLVM IR - Reviving the DebugIR pass
- InstCombine, graph rewriting, Equality saturation
- Why does GEP allow src and destination type to have different address spaces?