Hello, I need to append something to the global "llvm.global_ctors". This variable may or may not already be declared within the current module. If I lookup the global variable, I see that it supports a getOperand(i) and setOperand(i,c), but does not support any way that I can enlarge that array to add a new record. Any suggestions? -- Nick Johnson
On Mar 31, 2009, at 4:42 PM, Nick Johnson wrote:> Hello, > > I need to append something to the global "llvm.global_ctors". This > variable may or may not already be declared within the current module. > > If I lookup the global variable, I see that it supports a > getOperand(i) and setOperand(i,c), but does not support any way that I > can enlarge that array to add a new record.Hi Nick, You actually have to create a new ConstantArray with the desired elements, then remove the existing llvm.global_ctors constand and create a new one to replace it. Take a look at the GlobalOpt pass for examples of how to do this sort of thing. -Chris
Thanks, Just one question more: why does Constant::getVectorElements() operate on a SmallVector<T>, while ConstantArray::get() operate on a std::vector<T> ? What is the distinction between these uses? Thanks! Nick On Tue, Mar 31, 2009 at 7:49 PM, Chris Lattner <clattner at apple.com> wrote:> > On Mar 31, 2009, at 4:42 PM, Nick Johnson wrote: > >> Hello, >> >> I need to append something to the global "llvm.global_ctors". This >> variable may or may not already be declared within the current module. >> >> If I lookup the global variable, I see that it supports a >> getOperand(i) and setOperand(i,c), but does not support any way that I >> can enlarge that array to add a new record. > > Hi Nick, > > You actually have to create a new ConstantArray with the desired > elements, then remove the existing llvm.global_ctors constand and > create a new one to replace it. > > Take a look at the GlobalOpt pass for examples of how to do this sort > of thing. > > -Chris > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Nick Johnson
Seemingly Similar Threads
- [LLVMdev] Mutating the elements of a ConstantArray
- [LLVMdev] Mutating the elements of a ConstantArray
- [LLVMdev] Removing std::vector from APIs (was Re: Mutating the elements of a ConstantArray)
- [LLVMdev] Removing std::vector from APIs (was Re: Mutating the elements of a ConstantArray)
- [LLVMdev] Removing std::vector from APIs (was Re: Mutating the elements of a ConstantArray)