similar to: How to read String value of GlobalVariable?

Displaying 20 results from an estimated 500 matches similar to: "How to read String value of GlobalVariable?"

2016 Aug 24
2
Change GlobalValue Type/Initializer
Hi, I am trying to update the initializer of a global value and I have encounter two issues: The first one is that I can not change the type of the global value. Let say that I have the following variable: @.str = private unnamed_addr constant [6 x i8] c”Test0A\00", align 1 How can I change the ”Test0A\00” to ”OtherTest0A\00”. Is this possible? I know that you can change the initializer
2016 Aug 24
2
Change GlobalValue Type/Initializer
Hi Mehdi, Thank you for you answer. > Yes it is normal you *have* to use the same context to manipulate IR inside a Module. The context owns the module and destroying the context destroys everything that is created in the context. It is not clear to me what other context you could even manage to use here conceptually. Actually I was using llvm::getGlobalContext() in order to get the context.
2019 Mar 09
2
Cast a function parameter to GEP
Thanks Tim, I'll try to solve my problem ASAP, if I cannot maybe I'll some other clarifications. Thanks again On Sat, Mar 9, 2019, 06:03 Tim Northover <t.p.northover at gmail.com> wrote: > Hi Alberto, > > On Sat, 9 Mar 2019 at 05:50, Alberto Barbaro via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > i8* getelementptr inbounds ([7 x i8], [7 x i8]*
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
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 On Sat, Apr 20, 2013 at 3:37 PM, Sean Silva <silvas at purdue.edu> wrote:
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
2018 Mar 31
3
Writing tests with Filecheck without emitting output to stdin
That works. Thanks. One more followup question though. Once i run opt on bitcode, there is not useful output/transform on bitcode. this rpt files are extra. I am hoping to do something like this, ; RUN: FileCheck --input-file=a.rpt.gold --check-prefix=CHECK-A < a.rpt ; RUN: FileCheck --input-file=b.rpt.gold --check-prefix=CHECK-B < b.rpt i did not find much examples in tests hence
2013 Apr 20
0
[LLVMdev] How to cast Value* to ConstantDataArray*
On Sat, Apr 20, 2013 at 5: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); > } >
2018 Mar 31
4
Writing tests with Filecheck without emitting output to stdin
Hello I have pass operating on bitcode file which produces more than one equivalent representation. opt --my-pass <%s | Filecheck %s --my-pass generates files a.rpt b.rpt c.rpt . How do i write test without writing all 3 files to stdin. I have considered CHECK-LABEL for each. it creates bulky checks. Thanks Mahesh -------------- next part -------------- An HTML attachment was
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?
2019 Jan 28
2
Create a BlockAddress array from LLVM Pass
Hi Good day. For the following function local static constant array: static const __attribute__((used)) __attribute__((section("data"))) void *codetable[] = { &&RETURN, &&INCREMENT, &&DECREMENT, &&DOUBLE, &&SWAPWORD}; I have the following in the LLVM IR. @sampleCode.codetable = internal global [5 x i8*] [i8* blockaddress(@sampleCode, %19), i8*
2017 Apr 08
2
Getting a pointer to a i8 from a global variable that holds a constant string
Hello, I'm trying to get the pointer to the first element of a string (so that I can pass it to a function). The string itself is a constant kept in a global variable. My end goal is to generate the IR for something like "puts("Hello World")"; I'm stuck on the parameter part of the call instruction. So far I have something like this: const std::string& str =
2015 Jan 14
2
[LLVMdev] Bug in InsertElement constant propagation?
Hi, When I run opt on the following LLVM IR: define i32 @foo() { bb0: %0 = bitcast i32 2139171423 to float %1 = insertelement <1 x float> undef, float %0, i32 0 %2 = extractelement <1 x float> %1, i32 0 %3 = bitcast float %2 to i32 ret i32 %3 } -> It generates: define i32 @foo() { bb0: ret i32 2143365727 } While tracking the value I see that the floating point value
2019 Jan 29
2
[cfe-dev] Create a BlockAddress array from LLVM Pass
Sorry for emailing both group. As I will have a constant array of BlockAddress, what type I should use in Constant Array for its ArrayType declaration? I am creating the list in following way: unsigned int nBr = fit->second.size(); llvm::Constant *listBA[nBr]; unsigned int Idx = 0; for (std::set<llvm::BasicBlock *>::iterator it = fit->second.begin(); it != fit->second.end(); ++it)
2017 Oct 03
1
About LLVM Pass dependency
Hi Hongbin I am not quite familiar with AnalysisUsage, let me correct question a bit. I have read Writing Pass <http://llvm.org/docs/WritingAnLLVMPass.html#specifying-interactions-between-passes>, All examples that i see here are based on collecting information .i.e Analysis Passes. I wonder if this applies to Transformation passes also. e.g. void MyInliner::getAnalysisUsage(AnalysisUsage
2015 May 28
1
[LLVMdev] Passing ConstantDataArray to GetElementPtrInst
Hi, I'm having a hard time finding an answer to what I assume is a very basic idea. I'm trying to produce this llvm code using the LLVM api: %myString = alloca [13 x i8], i32 13 store [13 x i8] c"Hello world.\00", [13 x i8]* %myString %tmp1 = getelementptr [13 x i8]* %myString, i32 0, i32 0 %tmp2 = call i32 (i8*, ...)* @printf( i8* %tmp1 ) nounwind A simple Hello
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
2015 May 18
2
[LLVMdev] copy value of a global's data field to another global
getInitializer returns the complete initializer of the global. My globals are complex nested structs, from which I want to extract e.g. one double datafield. Example: >From a struct Stuct having double,array(3xint),float fields, I could extract the second int value using the index sequence 0,1,1 with getGetElementPtr. This gives me a constantPointer, but I would need to get a constInt...
2017 Sep 10
2
Performance of large llvm::ConstantDataArrays
On Sat, Sep 9, 2017 at 10:18 PM, Chris Lattner via llvm-dev < llvm-dev at lists.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,
2017 Oct 03
2
About LLVM Pass dependency
Hello I am working on pass which has dependency on multiple passes. Say D1,D2,D3 I used INITIALIZE_PASS_BEGIN INITIALIZE_PASS_DEPENDENCY(D1) INITIALIZE_PASS_DEPENDENCY(D2) INITIALIZE_PASS_DEPENDENCY(D3) INITIALIZE_PASS_END. While running it through opt tool it, I had to specify this D1,D2,D3 pass names to get this pass executed before my pass. Is there way, to let llvm pass manager to know