search for: constantdataarray

Displaying 20 results from an estimated 46 matches for "constantdataarray".

2013 Apr 21
2
[LLVMdev] How to cast Value* to ConstantDataArray*
ConstantDataArray * cda = cast<ConstantDataArray>(v); throws this error: Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Users/rcatlin1/lldb/llvm/include/llvm/Support/Casting.h, line 208 Thanks for the help. Richard Catlin O...
2013 Apr 20
2
[LLVMdev] How to cast Value* to ConstantDataArray*
I extended the LLVM Kaleidoscope example to support Strings. I added a StringExprAST, which has the virtual Codegen method impl as follows: Value *StringExprAST::Codegen() { StringRef r(Val); return ConstantDataArray::getString(getGlobalContext(), r, false); } I am trying to concatenate Strings and have a ConcatExprAST with its Codegen method. Upon trying to access the data in the ConstantDataArray, I need to cast the Value* back to a ConstantDataArray* in order to use the getAsString() method. I tried: Cons...
2013 Apr 20
0
[LLVMdev] How to cast Value* to ConstantDataArray*
...15 PM, Richard Catlin <richard.m.catlin at gmail.com>wrote: > I extended the LLVM Kaleidoscope example to support Strings. I added a > StringExprAST, which has the virtual Codegen method impl as follows: > > Value *StringExprAST::Codegen() { > StringRef r(Val); > return ConstantDataArray::getString(getGlobalContext(), r, false); > } > > I am trying to concatenate Strings and have a ConcatExprAST with its > Codegen method. Upon trying to access the data in the ConstantDataArray, I > need to cast the Value* back to a ConstantDataArray* in order to use the > getAsStr...
2012 Nov 16
2
[LLVMdev] porting to 3.1: ConstantDataArray
Hi, In llvm 3.0 llvm::ConstantArray had a ::getAsCString() method that returned the buffer as a std::string. Now it seems that 3.1 this method dissapeared. I found that llvm::ConstantDataArray has a method called getAsString(), but it returns a Constant*. What is the safe way to retrieve the pointer of the Constant array as a C string?
2012 Nov 16
0
[LLVMdev] porting to 3.1: ConstantDataArray
On 16 November 2012 13:55, charles quarra <charllsnotieneningunputocorreo at gmail.com> wrote: > In llvm 3.0 llvm::ConstantArray had a ::getAsCString() method that > returned the buffer as a std::string. Now it seems that 3.1 this > method dissapeared. > > I found that llvm::ConstantDataArray has a method called > getAsString(), but it returns a Constant*. In 3.1 ConstantDataArray has a getAsCString() which is exactly what you want. See here line 623: http://llvm.org/viewvc/llvm-project/llvm/tags/RELEASE_31/final/include/llvm/Constants.h?view=annotate Jay.
2015 May 28
1
[LLVMdev] Passing ConstantDataArray to GetElementPtrInst
...ring, i32 0, i32 0 %tmp2 = call i32 (i8*, ...)* @printf( i8* %tmp1 ) nounwind A simple Hello World example. But I can't seem to figure out what I'm supposed to pass to the GetElementPtrInst. For example, this snippet: std::vector<llvm::Value*> args; auto strValue = llvm::ConstantDataArray::getString(llvm::getGlobalContext(), llvm::StringRef("Hello world.")); std::vector<llvm::Value*> index_vector; index_vector.push_back(Builder.getInt32(0)); index_vector.push_back(Builder.getInt32(0)); auto valueAsPtr = Builder.CreateGEP(strValue, index_vector, "...
2017 Sep 10
2
Performance of large llvm::ConstantDataArrays
...ts.llvm.org> wrote: > > On Sep 7, 2017, at 11:06 PM, Chris Lovett via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > I'm running into some pretty bad performance in llc.exe when compiling > some large neural networks into code that contains some very large llvm::ConstantDataArrays, > some are { size=102,760,448 }. There's a small about of actual code for > processing the network, but the assembly is mostly global data. > > > Yes, llvm’s representation of constant arrays is insanity for cases like > this. Your case is bad, but just imagine the cost of...
2016 Aug 24
2
Change GlobalValue Type/Initializer
...load for the comparator operator (in the type class). So this will only check if the addresses of the type are the same and not if this is the same type. To have the same type, I need to create the initializer with the same context as the global variable: LLVMContext &C = gv->getContext(); ConstantDataArray *data = cast<ConstantDataArray>(ConstantDataArray::getString(C, ref, false)); gv->setInitializer(data); Is this normal? I am missing something? Greetings, JOHAN WEHRLI - Product and development Rue Galilée 7 CH-1400 Yverdon-les-Bains https://strong.codes <https://str...
2017 Sep 08
5
Performance of large llvm::ConstantDataArrays
I'm running into some pretty bad performance in llc.exe when compiling some large neural networks into code that contains some very large llvm::ConstantDataArrays, some are { size=102,760,448 }. There's a small about of actual code for processing the network, but the assembly is mostly global data. I'm finding that llc.exe memory spikes up around 30 gigabytes and the job takes 20-30 minutes compiling from bitcode. When I looked into it I found tha...
2019 Jan 28
2
Create a BlockAddress array from LLVM Pass
...gvar_ptr_abc = new GlobalVariable( /*Module=*/*fn->getParent(), /*Type=*/PointerTy, /*isConstant=*/false, /*Linkage=*/GlobalValue::InternalLinkage, /*Initializer=*/0, // has initializer, specified below /*Name=*/"labelTracker"); gvar_ptr_abc->setAlignment(16); Constant *blockItems = ConstantDataArray::get(fn->getContext(), tmp); gvar_ptr_abc->setInitializer(blockItems); I get error with following: Unsupported type in Type::getScalarTy Can anyone suggest what I suppose to do? It is definitely related to my type declaration and BlockAddress items, but I don't know what it is exactly. -...
2015 Jan 14
2
[LLVMdev] Bug in InsertElement constant propagation?
...} -> It generates: define i32 @foo() { bb0: ret i32 2143365727 } While tracking the value I see that the floating point value is changed while folding insertElement into a constant expression. In Constant.cpp line 902, we convert the APFloat into float then convert it back when creating the ConstantDataArray. This causes the float value to be changed. I'm not entirely positive why the float value returned by converToFloat has a different memory representation than the original int value, there must be a C++ rule that I'm missing. d if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {...
2019 Jan 29
2
[cfe-dev] Create a BlockAddress array from LLVM Pass
...4 pm, Eli Friedman <efriedma at quicinc.com> wrote: > Please don’t send questions to both cfe-dev and llvm-dev; usually one or the other is more appropriate (in this case, it’s llvm-dev, since there’s no clang code involved). > > > I think you meant to call ConstantArray::get, not ConstantDataArray::get. (We should probably fix ConstantDataArray::get() to use enable_if or something like that, so your example fails to compile instead of generating a weird runtime error.) > > -Eli > > From: cfe-dev <cfe-dev-bounces at lists.llvm.org> On Behalf Of Mustakimur Rahman Khandaker (M...
2016 Aug 24
2
Change GlobalValue Type/Initializer
...class). So this will only check if the addresses of the type are the same and not if this is the same type. >> >> To have the same type, I need to create the initializer with the same context as the global variable: >> >> LLVMContext &C = gv->getContext(); >> ConstantDataArray *data = cast<ConstantDataArray>(ConstantDataArray::getString(C, ref, false)); >> gv->setInitializer(data); >> >> Is this normal? I am missing something? > > Yes it is normal you *have* to use the same context to manipulate IR inside a Module. The context ow...
2017 Apr 08
2
Getting a pointer to a i8 from a global variable that holds a constant string
...t;value(); llvm::ArrayType* type = llvm::ArrayType::get(llvm::IntegerType::get(m_context, 8), str.size()+1); llvm::GlobalVariable* var = new llvm::GlobalVariable(m_module, type, true, llvm::GlobalValue::PrivateLinkage, nullptr, ".str"); var->setAlignment(1);; llvm::Constant* c = llvm::ConstantDataArray::getString(m_context, str); var->setInitializer(c); The part below is the one I have problems with: llvm::ConstantInt* const_int32_12 = llvm::ConstantInt::get(m_context, llvm::APInt(32, llvm::StringRef("0"), 10)); std::vector<llvm::Constant*> const_ptr_14_indices; const_ptr_14_...
2019 Nov 20
2
Get the address of ConstantDataArray
Hi all, I have a global array declared as: table = internal constant [8 x [256 x i32]] ... At the moment I'm able to get the reference to table using Constant* g_var = cast<GlobalVariable>(I.getOperand(0))->getInitializer(); ( please consider I to be a GetElementPtrInst object ). Now I would like to understand how to get the address of table[2][3], for instance, considering that I
2012 Sep 05
1
[LLVMdev] Calling a function with a pointer to a global char array as argument
Hello; Thanks to Eli for the pointer to the ConstantDataArray::getString() fucntion. Now I am trying to declare a global char array with the content "hi" and call a function "print" (which takes a char pointer and return an insteger. I am doing the following in the code - Function Creation: PointerType* array = PointerType::get(IntegerT...
2012 May 09
1
[LLVMdev] 3.1 API Breakage
On Tue, May 8, 2012 at 7:16 PM, Albert Graef <Dr.Graef at t-online.de> wrote: > Now I've run into another issue: The ConstantArray::get() method for > constructing a string  constant from a char* seems to be gone. Is there > a replacement for that somewhere? ConstantDataArray::getString. IRBuilder::CreateGlobalString might also be useful in some cases. > BTW, this isn't mentioned in the release notes yet. Hmm... might be worth a mention. -Eli
2013 Jun 25
2
[LLVMdev] get value
...s may be a trivial question, but I cannot get fields from a Value type. If my Value is i32 1, how can I store 1 in a different structure (an integer) ? For the type, I have getType(). For the value, I see no method in Value.h. I tried to cast to ConstantExpr and then to get operands, or cast to ConstantDataArray and then use getAsString(), but is not working. How should I get the value? Thank you ! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130625/a8f88bfb/attachment.html>
2013 Jun 25
4
[LLVMdev] get value
...ut I cannot get fields from a Value type. > > >If my Value is i32 1, how can I store 1 in a different structure (an integer) ? For the type, I have getType(). For the value, I see no method in Value.h. > > > >I tried to cast to ConstantExpr and then to get operands, or cast to ConstantDataArray and then use getAsString(), but is not working. How should I get the value? > > >Thank you ! > > > >_______________________________________________ >LLVM Developers mailing list >LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu >http://lists.cs.uiuc.edu/mailman/l...
2012 Dec 19
2
[LLVMdev] GetElementPtrConstantExpr
Ok, now it's arising another problem. IR code that I obtain is the following: i8* bitcast ([5 x i8] c"hello\00" to i8*) generated from instructions: ConstantExpr::getBitCast (ConstantDataArray::getString (getGlobalContext (), "hello"), PointerType::get (Type::getInt8Ty (getGlobalContext ()), 0)) but the LLC tool says: invalid cast opcode for cast from '[5 x i8]' to 'i8*'. Any help? 2012/12/18 Óscar Fuentes <ofv at wanadoo.es> > Alessio Giovanni Bar...