search for: setinitial

Displaying 20 results from an estimated 59 matches for "setinitial".

Did you mean: getinitial
2016 Aug 24
2
Change GlobalValue Type/Initializer
...t 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 with setInitializer but the global value’s type will not be the same. For now, the only way I found was to create a new global value and to change all theses uses. The second problem that I have is with the function Verifier::visitGlobalVariable. Sometimes, the verifier tells me that the initializer type does no...
2009 Jun 18
3
[LLVMdev] Initialising global Array
...exactly "NumEdges" constants are pushed to the "Initializer": > Initializer[i] = zeroc; > .. > Initializer[i] = minusonec; > .. And then I set the initializer for the array: > Constant *init = llvm::ConstantArray::get(ATy, Initializer); > Counters->setInitializer(init); What am I doing wrong? I still get: > @OptimalEdgeProfCounters = internal global [2 x i32] zeroinitializer; <[2 x i32]*> [#uses=2] Thanks, Andi
2009 Jun 18
0
[LLVMdev] Initialising global Array
...alValue::InternalLinkage, Constant::getNullValue(ATy), "OptimalEdgeProfCounters1", &M); Initializer[0] = zeroc; Initializer[1] = minusonec; Initializer[2] = minusonec; Initializer[3] = zeroc; Constant *init = llvm::ConstantArray::get(ATy, Initializer); Counters->setInitializer(init); DOUT << "Initializer:: \n"; for( int i = 0; i < Initializer.size(); ++i ) { DOUT << "Initializer["<<i<<"]: " << Initializer[i] << "\n"; } } static void andiTest2(Module &M) { int NumEdges = 4;...
2012 Jul 04
2
[LLVMdev] Bogus assert in VMCore/Instructions.cpp CallInst::Create?
..._id.push_back(ConstantInt::get( block->getContext(), APInt(64, StringRef("0"), 10))); s2_id.push_back(ConstantInt::get( block->getContext(), APInt(64, StringRef("0"), 10))); g1->setInitializer(ar1); g2->setInitializer(ar2); Type *tys = { Type::getInt32Ty(block->getContext()) }; Function *annot = Intrinsic::getDeclaration( F->getParent(), Intrinsic::annotation,...
2004 Oct 10
1
[LLVMdev] Re: Hide visible string in variable
...<< gI->getName()<<gI->getInitializer(); } With *gI, I could get all string With gI->getName, I could get the global variable name. With gI->getInitializer(), I could get the init value for the GV. Next, what I want to do is to modify the value of the GV, and I tried to use setInitializer(), but I don't know to do it. setInitializer() need contant parameter. I tried several ways, but I failed. As you said, I can do it like in C level. For C, if I can get the address of the GV, I can read the value and do XOR and then write it back. But for this case, I don't know how to...
2016 Aug 24
2
Change GlobalValue Type/Initializer
...n 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 with setInitializer but the global value’s type will not be the same. >> For now, the only way I found was to create a new global value and to change all theses uses. > > That’s the right thing to do: you need to create a new GV and replace the old one with the new one. > > > >> &gt...
2012 Jul 04
0
[LLVMdev] Bogus assert in VMCore/Instructions.cpp CallInst::Create?
...et( block->getContext(), > APInt(64, StringRef("0"), 10))); > s2_id.push_back(ConstantInt::get( block->getContext(), > APInt(64, StringRef("0"), 10))); > > g1->setInitializer(ar1); > g2->setInitializer(ar2); > > Type *tys = { Type::getInt32Ty(block->getContext()) }; > Function *annot = Intrinsic::getDeclaration( F->getParent(), > Intrinsic::annotation, >...
2015 May 17
2
[LLVMdev] copy value of a global's data field to another global
...this to repalece an argumrnt of an instruction like: I->setOperand(someArgumentIndex,pConst); However, getGetElementPtr returns a pointerType, which holds the actual type as sub_type. This is a problem when I want to use the data from one global for the initializer of another pGvar->setInitializer(__NeedsAFloatTy_here__); //not pointerTy So what I'm trying to do is copy some data-fields of one global to another. I know the 'index-trace' used in getGetElementPtr, but I need the actual type, not 'covered' by a pointerType. Thank You! Alexander
2012 Nov 10
2
[LLVMdev] Forward references of globals in .ll files
...But if I rearrange the statements to: @a2 = global i8 addrspace(1)* @a @a = addrspace(1) global i8 0 then I get an ugly assertion failure: Assertion failed: (InitVal->getType() == getType()->getElementType() && "Initializer type must match GlobalVariable type"), function setInitializer, file /Users/jholewinski/projects/llvm/src/llvm/lib/VMCore/Globals.cpp, line 168. Looking at the debugger, I see that InitVal (the initializer for @a2) has type i8*, which looks incorrect as it drops the addrspace from the definition of @a. Before I go too far into this, should this IR work?...
2010 Feb 26
4
[LLVMdev] Massive Number of Test Failures
...sts : 66 > > [x86_64-off-dbg]: Expected Passes : 5001 > [x86_64-off-dbg]: Expected Failures : 33 > [x86_64-off-dbg]: Unsupported Tests : 66 > [x86_64-off-dbg]: Unexpected Failures: 5 > > Why would changing the test harness change the result of the tests? SDUse::setInitial should initialize List to null in your patch. You're probably seeing random uninitialized data noise without that. (Though valgrind wouldn't notice this because of the aggressive reuse of allocated memory.) Also, the replacement getOperandNo is returning the index in the use list, rather t...
2015 Mar 05
4
[LLVMdev] global variable
Hi all, I am newbie for llvm. I just create a global variable, there are some statements in my pass like: LoadInst* int64_64 = new LoadInst(pthreadPID, "", false, OptAplusOne); int64_64->setAlignment(8); int64_64->dump(); LoadInst* int32_65 = new LoadInst(gvar_int32_myFlag, "", false, OptAplusOne); int32_65->setAlignment(4);
2019 Jan 28
2
Create a BlockAddress array from LLVM Pass
.../*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. -------------- next part -------------- An HTML attachment wa...
2015 May 18
2
[LLVMdev] copy value of a global's data field to another global
...and(someArgumentIndex,pConst); >> >> However, getGetElementPtr returns a pointerType, which holds the actual >> type >> as sub_type. >> This is a problem when I want to use the data from one global for the >> initializer of another >> >> pGvar->setInitializer(__NeedsAFloatTy_here__); //not pointerTy >> >> So what I'm trying to do is copy some data-fields of one global to >> another. I know the 'index-trace' used in getGetElementPtr, but I need >> the actual type, not 'covered' by a pointerType. >> &g...
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 mapping the global variables in Stringmap? I need to identify the global variable with its name in the IR to be able to load and store its values. Thanks -- * Rasha Salah Omar Msc Student at E-JU...
2015 Feb 27
1
[LLVMdev] Replacing an initializer
Hi all, suppose I would like to change the initial value of a global. Is the supposed way to change the initializer via const_global_iterator I I->setInitializer(newOne) ? afaik, newOne is a constant - right? Is the original Initializer automatically purged or do I need to delete it? thanks Alex
2012 Nov 10
0
[LLVMdev] Forward references of globals in .ll files
...: > > @a2 = global i8 addrspace(1)* @a > @a = addrspace(1) global i8 0 > > then I get an ugly assertion failure: > > Assertion failed: (InitVal->getType() == getType()->getElementType() && > "Initializer type must match GlobalVariable type"), function setInitializer, > file /Users/jholewinski/projects/llvm/src/llvm/lib/VMCore/Globals.cpp, line > 168. > > Looking at the debugger, I see that InitVal (the initializer for @a2) has > type i8*, which looks incorrect as it drops the addrspace from the > definition of @a. > > Before I go to...
2004 Oct 12
1
[LLVMdev] Re: Hide visible string in variable (Chris Lattner)
...do what I want, but how could create/construct a new Value with my owner value? for 3,4,5, those should work well. I would really appreciated if you can give me a very simple example to show me how to do it. > 3. Change the initializer of the global variable to the new constant with > setInitializer(). > 4. Clear the "constant" flag on the string, because the program will be > dynamically hacking on the string: GV->setConstant(false); > 5. Insert the for loop that translates the string when main runs. > > For #5, write the for loop you want, compile it with...
2010 Jun 16
0
[LLVMdev] Optimization - Converting Globals to Constants
...?  If so, what do I need to do to give the variables an initial value and make sure that the Global Variable Optimizer can recognize that these variables can indeed be optimized into constants? You'll essentially have to do it yourself, I think, but it's not hard: just call GlobalVariable::setInitializer and GlobalVariable::setConstant on the globals in question once the bitcode is loaded, then run instcombine to propagate the constants. I don't think globalopt has enough information in your situation to do the optimization in question. -Eli
2009 Oct 06
0
[LLVMdev] 2.6/trunk Execution Engine question
...int argc, char** argv) { // Test JITting a variable without JITting any functions.' Module* mod = new Module("test", getGlobalContext()); GlobalVariable* gv = cast<GlobalVariable>(mod->getOrInsertGlobal("TestGV", Type::getInt32Ty(getGlobalContext()))); gv->setInitializer(ConstantInt::get( Type::getInt32Ty(getGlobalContext()), 24601)); ModuleProvider* modp = new ExistingModuleProvider(mod); InitializeNativeTarget(); std::string errstring; ExecutionEngine* eeng = ExecutionEngine::create(modp, false, &errstring, CodeGenOpt::Default, true); if ( een...
2015 Jun 08
4
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...bles. > + for (Module::global_iterator I = M.global_begin(), E = M.global_end(); > + I != E; ++I) { > + if (!I->hasAvailableExternallyLinkage()) > + continue; > + if (I->hasInitializer()) { > + Constant *Init = I->getInitializer(); > + I->setInitializer(nullptr); > + if (isSafeToDestroyConstant(Init)) > + Init->destroyConstant(); > + } > + I->removeDeadConstantUsers(); > + NumVariables++; > + } > > Do you need to set the linkage of global variables to external? I noticed > that Function::d...