Displaying 20 results from an estimated 40000 matches similar to: "[LLVMdev] Re: global variable"
2006 Jun 06
0
[LLVMdev] Re: global variable
Note: please don't email me directly, please email the llvmdev list.
On Tue, 6 Jun 2006, Lan Bai wrote:
>> You probably want to pass Gv in as an argument to the call? I don't know
>> what you're trying to do, so I can't help without more details.
>>
>> No, Gv is not used as an argument to the call. The return value of the call
>> is to be assigned
2011 Oct 05
0
[LLVMdev] replacing a global variable by a constant
Hi nada,
> i want replacing a global variable by a constant value for erase instruction.
I'm not sure what you mean exactly. A GlobalVariable has pointer type. Do you
want to replace that pointer by a constant pointer? Or is it rather that you
want to say that the contents of the memory pointed to by the GlobalVariable is
constant, and have all places that load that GlobalVariable
2011 Oct 05
2
[LLVMdev] replacing a global variable by a constant
hi
i want replacing a global variable by a constant value for erase
instruction. i had seen the code that as follows
for (llvm::GlobalVariable::use_iterator U = gv->use_begin(); U !=
gv->use_end();--U ) {
llvm::Instruction *I = llvm::cast<llvm::Instruction>(U);
I->replaceAllUsesWith(constPtr);
I->eraseFromParent();
}
but i dont know how can declare constptr.
2013 Sep 10
1
[LLVMdev] Global Variable Recall
Hi All,
I need to call global variable by its name from the following code
for(Function::iterator i=F->begin();i!=F->end();++i)
{
BasicBlock*Bb =&*i;
GlobalVariable* GV = new GlobalVariable(type,false,
F->getLinkage(),0, "F$"+Bb->getName());
GV->setInitializer(Constant::getNullValue (typ));
GList.push_back(GV);
}
Could I solve that by
2012 Sep 19
0
[LLVMdev] newbie question on getelementptr
Hi Óscar,
Thank you for your prompt reply. Unfortunately, I still need more guidance
as using the Demo page to generate C++ code didn't result in a global
variable being used.
Basically, I'm following your advice to use a LoadInst:
Value *v = new LoadInst(result, "", theBasicBlock);
Function *myfn = cast<Function>(v);
I was not sure how I could get a BasicBlock for the
2008 Dec 05
1
[LLVMdev] replacing a global variable by a constant
Thanks a lot for your help Matthijs! :)
basically this does the job quite nicely I think:
for (llvm::GlobalVariable::use_iterator U = gv->use_begin(); U !=
gv->use_end(); ++U) {
llvm::Instruction *I = llvm::cast<llvm::Instruction>(U);
I->replaceAllUsesWith(constPtr);
I->eraseFromParent();
}
Cheers,
Ralf
Matthijs Kooijman wrote:
> Hi Ralf,
>
>
>> I
2006 May 01
0
[LLVMdev] printf decleration
Ok, I think I figured it out. I talked to someone, and we figured out
that when I make a call to printf with a constant string, I need to make
a global variable and use getElementPtr to reference it. The modified
call for accessing the printf is:
/* m is Module*, f is Function*, i is Instruction* */
Constant* constStr = ConstantArray::get("test\n");
GlobalVariable* gv =
2006 Jun 30
1
[LLVMdev] instruction sequence
I'm trying to insert a call to fprintf(stderr, ...). I've looked at
the emitted assembly from llvm-gcc, and it consists of a LoadInst (of
stderr) and CallInst. It looks like this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%tmp.1 = load %struct._IO_FILE** %stderr ; ty=%struct._IO_FILE*
%tmp.0 = call int (%struct._IO_FILE*, sbyte*, ...)* %fprintf(%struct._IO_FILE* %tmp.1, sbyte*
2012 Dec 05
0
[LLVMdev] how to get and modify a global variable inside a module
Hi Dong Chen,
I realized you are actually executing the IR, right? I am not sure if
the things I mentioned apply in that case. Actually, I wrote a
optimization pass that modify the IR. It modifies global variables and
the final IR is intended to be compiled.
A snippet of what I do looks like this:
class TestClass : public llvm::ModulePass {
public:
TestClass() : llvm::ModulePass(TestClass::ID)
2007 Jul 17
0
[LLVMdev] BasicCallGraph patch
On Tue, 17 Jul 2007, Zhongxing Xu wrote:
> I am doing inter-procedural static analysis, so I need to do DFS of call
> graph. llvm-gcc sometimes generates this kind of call instruction, which
> cause the call graph to be incomplete.
>
> But thanks for your information, instcombine really solves the problem.
Happy to help. You'll probably find that other optimizations help as
2006 Jun 25
1
[LLVMdev] adding args to func call
This question is similar to Ryan Lefever's post on May 1, 2006 about
printf declaration. In my case, I want to insert fprintf(stderr,
...) calls. I'm new to LLVM, and I don't know what's the recipe for
putting together the arguments. Can someone give me basic
instructions or point me in the direction on what to do? I can't find
any more documentation on this. Thanks!
2007 Jul 17
2
[LLVMdev] BasicCallGraph patch
I am doing inter-procedural static analysis, so I need to do DFS of call
graph. llvm-gcc sometimes generates this kind of call instruction, which
cause the call graph to be incomplete.
But thanks for your information, instcombine really solves the problem.
On 7/17/07, Chris Lattner <sabre at nondot.org> wrote:
>
> On Thu, 12 Jul 2007, Zhongxing Xu wrote:
> > The current
2010 Jun 01
2
[LLVMdev] How to create global string array? (user question)
I am trying to create such module with API (it's equivalent to c++:
const char* ss[] = {"s1","s2"};):
@ss = global [2 x i8*] [i8* getelementptr inbounds ([3 x i8]* @.str1,
i32 0, i32 0), i8* getelementptr inbounds ([3 x i8]* @.str2, i32 0, i32
0)] ; <[2 x i8*]*> [#uses=0]
@.str1 = private constant [3 x i8] c"s1\00", align 1 ; <[3 x i8]*> [#uses=1]
2012 Sep 09
0
[LLVMdev] Create target with alternate syntax for globals?
2012/9/9 ryan baird <ryanrbaird at gmail.com>:
> I'm working on building a target for llvm that's the intermediate language
> of another compiler, so that the other compiler can benifit from llvm's
> optimization passes.
>
> I essentially made a copy of the mips backend, and then started changing the
> output to match the intermediate language of the compiler.
2013 Aug 02
1
[LLVMdev] replacing GetElementPtrConstantExpr with GetElementPtrInst ... sometimes
Hi
During a pass, the XCore target lowers thread local global variables by turning them into global variable arrays indexed by the (max 8) thread ID.
(see XCoreLowerThreadLocal.cpp)
This works fine for instructions e.g. GetElementPtrInst
But can't be done for constants e.g. GetElementPtrConstantExpr
Thus I would like to replace GetElementPtrConstantExpr with GetElementPtrInst when it is
2010 Feb 16
3
[LLVMdev] Creating a global variable in JIT context
I'm trying to create a global variable initialized to zero, and return
its value from a newly created function, in JIT context. I'm keeping
all types as i32 for the moment, and I only have the one module
object.
This is the code I have for creating the global variable:
const Type *type = Type::getInt32Ty(getGlobalContext());
// Constant *zerov = Constant::getNullValue(type);
Constant
2004 Jun 17
0
[LLVMdev] generating instructions with embedded ConstantExprs from within LLVM
On Thu, 17 Jun 2004, Patrick Meredith wrote:
> How is this done? Everything logical I have tried has failed, here was
> one attempt:
Can you give a few more details about what you are doing? Are you running
the verifier before writing out bytecode? Is your code operating as a
pass? Can you send a dump of the generated LLVM code?
> Constant *C = (Constant*)
2007 Jul 17
0
[LLVMdev] BasicCallGraph patch
On Thu, 12 Jul 2007, Zhongxing Xu wrote:
> The current BasicCallGraph will miss call sites like this:
> %tmp86 = call i8* (...)* bitcast (i8* ()* @find_ispell to i8* (...)*)( )
> ; <i8*> [#uses=1]
>
> Here the direct user of @find_ispell is a ConstantExpr.
> I added several lines of code to address this case.
> Below is the output of command: svn diff
2010 Feb 16
0
[LLVMdev] Creating a global variable in JIT context
Do you use load to get the value of V? If not then you probably return i32*
instead of i32.
Victor
On 16 February 2010 11:26, Russell Wallace <russell.wallace at gmail.com>wrote:
> I'm trying to create a global variable initialized to zero, and return
> its value from a newly created function, in JIT context. I'm keeping
> all types as i32 for the moment, and I only have
2020 Jun 03
2
Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
I don't think it's the same problem as you described. By printing I meant
calling printf function and passing my global variable as one of the
arguments.
My code:
Instruction* InstructionVisitor::incrementGlobalKey(Instruction* I) {
IRBuilder<> Builder(I->getContext());
Builder.SetInsertPoint(I->getNextNode());
GlobalVariable* key =