search for: constantarray

Displaying 20 results from an estimated 182 matches for "constantarray".

2006 Mar 27
1
[LLVMdev] could you give me some advice ?
excuse me for bother you again . a little supplement Constant* c = findValue(m,"E1$entry"); Constant* c2 = findValue(m,"E1$str"); I can get string object from c2 string s = cast<ConstantArray>(c2)->getAsString(); but it is not applicable for c string s= cast<ConstantArray>(c)->getAsString(); // Assert Fail because c is ConstantExpr::GetElementPtr actually , not ConstantArray so I have to get string object like this : GlobalVariable* gv = cast<GlobalVariable>(c-...
2012 Sep 05
2
[LLVMdev] llvm::ConstantArray::get(llvm::LLVMContext&, llvm::StringRef, bool) deprecated?
Hi all; I have been trying to use the llvm::ConstantArray::get(llvm::LLVMContext&, llvm::StringRef, bool) function but seems it has been deprecated. ProfileDependence.cpp:68:73: error: no matching function for call to ‘llvm::ConstantArray::get(llvm::LLVMContext&, llvm::StringRef, bool)’ ProfileDependence.cpp:68:73: note: candidate is: /home/arnie...
2009 Jul 04
2
[LLVMdev] Pool Allocation Segfaulting with opt
...d /home/vadve/simmon12/llvm/llvm/projects/llvm-poolalloc/Debug/lib/libLLVMDataStructure.so -load /home/vadve/simmon12/llvm/llvm/projects/llvm-poolalloc/Debug/lib/poolalloc.so -poolalloc hello.bc > hello.pool 0 opt 0x08469ccb 1 libLLVMDataStructure.so 0x0022f5a4 llvm::ConstantArray::classof(llvm::Value const*) + 30 2 libLLVMDataStructure.so 0x0022f57a bool llvm::isa_impl<llvm::ConstantArray, llvm::Constant>(llvm::Constant const&) + 30 3 libLLVMDataStructure.so 0x0022e942 llvm::isa_impl_wrap<llvm::ConstantArray, llvm::Constant const, llvm::Constant const&g...
2017 Dec 17
2
Removing constants from a constant array?
Hi, I’m currently writing a LLVM pass and would like to modify a constant array based on some basic analysis. Is there any way to simply remove entries (`llvm::Constant`) from an array (`llvm::ConstantArray`)? Replacing all uses with an undefined value doesn’t work as the array is terminated by an undefined value, subsequent elements thus are ignored at runtime. I’d rather avoid re-creating the entire array from scratch and replace the existing array with it but I’m afraid there’s not many other optio...
2011 Oct 20
2
[LLVMdev] common type at compile time?
...#39;m a bit confused. For the Type did you mean something like: ArrayType *type = ArrayType::get(Type::getInt8PtrTy(M.getContext()), 4); This does not work, it gives me ""Wrong type in array element initializer" at runtime. Also it doesn't look like ConstantExpr inherits ConstantArray, so I'm not sure how I could use this instead. Thanks On Thu, Oct 20, 2011 at 12:04 PM, John Criswell <criswell at illinois.edu> wrote: > On 10/20/11 10:43 AM, ret val wrote: >> >> I'm trying to create a ConstantArray(whose contents will be of types >> Function*...
2011 Oct 20
3
[LLVMdev] common type at compile time?
I'm trying to create a ConstantArray(whose contents will be of types Function*, GlobalVariable *) so I can immediately create a new GlobalVariable(that will be in its own section). I'm doing this so I have these address stored. In order to create this ConstantArray I need a valid ArrayType, but I'm not sure what to use for the...
2012 Jan 17
1
[LLVMdev] [LLVM] Modify ConstantArray object contents
Hi all. Is it allowed to modify ConstantArray object within setOperand method, or it is better to leave old ConstantArray object and create new one? Thanks! -Stepan.
2010 Jul 16
2
[LLVMdev] Strange behavior when converting arrays to strings
Hello, I found saw some strange behavior (to me) when converting constant arrays to strings. Consider the following example: std::string Text = "HelloWorld"; unsigned TextLengthBefore = Text.length(); ConstantArray *pArray = dyn_cast<ConstantArray>(llvm::ConstantArray::get(pModule->getContext(), Text, true)); unsigned NumElements = pArray->getNumOperands(); Text = pArray->getAsString(); unsigned TextLengthAfter = Text.length(); After running this example here are the values in each varia...
2010 Jul 28
1
[LLVMdev] Strange behavior when converting arrays to strings
Hi Javier, > I found saw some strange behavior (to me) when converting constant > arrays to strings. Consider the following example: > > std::string Text = "HelloWorld"; > > unsigned TextLengthBefore = Text.length(); > > ConstantArray *pArray = > dyn_cast<ConstantArray>(llvm::ConstantArray::get(pModule->getContext(), > Text, true)); from Constants.h: /// This method constructs a ConstantArray and initializes it with a text /// string. The default behavior (AddNull==true) causes a null terminator to ///...
2011 Oct 20
0
[LLVMdev] common type at compile time?
...ume that creates an ArrayType of 4 elements whose elements are pointers to 8-bit values. If so, then this is what I meant. > This does not work, it gives me ""Wrong type in array element > initializer" at runtime. > > Also it doesn't look like ConstantExpr inherits ConstantArray, so I'm > not sure how I could use this instead. What I meant here is that each element (Function *, GlobalVariable *) that you want to put into the ConstantArray will need to be casted to an i8 * type. To do the casting, you will need to use a bitcast ConstantExpr instead of a BitCastI...
2011 Oct 20
0
[LLVMdev] common type at compile time?
On 10/20/11 10:43 AM, ret val wrote: > I'm trying to create a ConstantArray(whose contents will be of types > Function*, GlobalVariable *) so I can immediately create a new > GlobalVariable(that will be in its own section). I'm doing this so I > have these address stored. In order to create this ConstantArray I > need a valid ArrayType, but I'm not sure...
2012 Feb 17
4
[LLVMdev] llvm-gcc compilation and ConstantArray::getAsString
Hello there I'm trying to compile llvm-gcc, but the compilation fails. This is due to the fact that the ConstantArray class does no longer have the getAsString method. It has been actually removed on Jan 31 (commit 6a89228faca4b30c4abc29b5dec98bdac011ea4c). Is there a patch for llvm-gcc which overcomes this problem? I've just svn-updated my working copy but it didn't change anything. Regards -- G...
2010 Jul 28
0
[LLVMdev] Strange behavior when converting arrays to strings
...s.uiuc.edu Subject: [LLVMdev] Strange behavior when converting arrays to strings Hello, I found saw some strange behavior (to me) when converting constant arrays to strings. Consider the following example: std::string Text = "HelloWorld"; unsigned TextLengthBefore = Text.length(); ConstantArray *pArray = dyn_cast<ConstantArray>(llvm::ConstantArray::get(pModule->getContext(), Text, true)); unsigned NumElements = pArray->getNumOperands(); Text = pArray->getAsString(); unsigned TextLengthAfter = Text.length(); After running this example here are the values in each varia...
2009 Mar 31
2
[LLVMdev] Mutating the elements of a ConstantArray
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
2009 Mar 31
0
[LLVMdev] Mutating the elements of a ConstantArray
...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
2009 Apr 01
1
[LLVMdev] Mutating the elements of a ConstantArray
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 app...
2006 Mar 25
1
[LLVMdev] could you give me some advice ?
hi I have one llvm program like this : ... ; define ConstantArray "E1$str" = internal constant [3 x sbyte] c"E1\00" ; use getPtrPtrFromArrayPtr to define SByte* from ConstantArray "E1$entry" = internal constant sbyte* getelementptr ([3 x sbyte]* "E1$str", uint 0, uint 0) ... when i want to get std::string...
2010 Jun 01
2
[LLVMdev] How to create global string array? (user question)
...0)] ; <[2 x i8*]*> [#uses=0] @.str1 = private constant [3 x i8] c"s1\00", align 1 ; <[3 x i8]*> [#uses=1] @.str2 = private constant [3 x i8] c"s2\00", align 1 ; <[3 x i8]*> [#uses=1] Code below doesn't compile because to initialize GlobalVariable I need ConstantArray*, ConstantArray::get requires vector<Constant*>, but getelementptr is an instruction and it's not Constant*, but Value*. What is the correct way to create such module? It's really tye Yuri --- c++ code --- #include "llvm/LLVMContext.h" #include "llvm/Module.h"...
2012 Jul 23
2
[LLVMdev] static constant structs
...is is the correct forum in which to ask this question. Currently I am writing code meant to compile with LLVM 3.0. I am trying to figure out, using the C++ API, how to create a constant static struct, or the equivalent. Since I am copying data from existing C structs, I am currently I am using a ConstantArray global variable, and then pointer casting it to the appropriate type when I use it, but this seems overly clunky. Constant *cip = ConstantArray::get( ctx(), StringRef((char *)&addr_, sizeof(addr_)), false); return new GlobalVariable( *mod(), cip->getType(), true,...
2009 Jul 06
0
[LLVMdev] Pool Allocation Segfaulting with opt
...lvm/projects/llvm-poolalloc/Debug/lib/libLLVMDataStructure.so > -load > /home/vadve/simmon12/llvm/llvm/projects/llvm-poolalloc/Debug/lib/poolalloc.so > -poolalloc hello.bc > hello.pool > 0 opt 0x08469ccb > 1 libLLVMDataStructure.so 0x0022f5a4 > llvm::ConstantArray::classof(llvm::Value const*) + 30 > 2 libLLVMDataStructure.so 0x0022f57a bool > llvm::isa_impl<llvm::ConstantArray, llvm::Constant>(llvm::Constant > const&) + 30 > 3 libLLVMDataStructure.so 0x0022e942 > llvm::isa_impl_wrap<llvm::ConstantArray, llvm::Constant const...