search for: hasinitializer

Displaying 20 results from an estimated 23 matches for "hasinitializer".

2012 Sep 06
3
[LLVMdev] Preferred alignment of globals > 16bytes
I recently noticed that all globals bigger than 16 bytes are being 16 byte aligned by LLVM (assuming there isn't an explicitly requested alignment). I'd really rather avoid this, at least for the XCore backend. I tracked this down to the following code in TargetData.cpp: if (GV->hasInitializer() && GVAlignment == 0) { if (Alignment < 16) { // If the global is not external, see if it is large. If so, give it a // larger alignment. if (getTypeSizeInBits(ElemType) > 128) Alignment = 16; // 16-byte alignment. } } I was a bit surp...
2011 Mar 08
2
[LLVMdev] TargetData::getPreferredAlignment(const GlobalVariable *GV) is strange ...
...ariable *GV) const { const Type *ElemType = GV->getType()->getElementType(); unsigned Alignment = getPrefTypeAlignment(ElemType); if (GV->getAlignment() > Alignment) Alignment = GV->getAlignment(); ==================== confusion starts ======================== if (GV->hasInitializer()) { if (Alignment < 16) { // If the global is not external, see if it is large. If so, give it a // larger alignment. if (getTypeSizeInBits(ElemType) > 128) Alignment = 16; // 16-byte alignment. } } ==================== confusion ends =================...
2012 May 23
0
[LLVMdev] lli unable to resolve symbol _ZNKSt3__16locale9use_facetERNS0_2idE in bitcode
...e to me that lli should define __dso_handle if it's declared in the module. You could module tools/lli/lli.cpp to add a global: char *dummy_dso_handle = 0; and tie it to __dso_handle via. if (GlobalVariable *DSO = Mod->getGlobalVariable("__dso_handle")) if (!DSO->hasInitializer()) EE->updateGlobalMapping(DSO, &dummy_dso_handle); somewhere in main(), say after disabling lazy compilation. Entirely untested though; we might need to give dummy_dso_handle a real value. Nick > tia > > On 5/21/2012 2:46 PM, Ashok Nalkund wrote: >> On 5/21/2012 11...
2016 Aug 24
2
Change GlobalValue Type/Initializer
...lue 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 not match the global variable type even when this is the case. This function will do the following check: if (GV.hasInitializer()) { Assert(GV.getInitializer()->getType() == GV.getType()->getElementType(), "Global variable initializer type does not match global " "variable type!", &GV); But I did not find any overload for the comparator operator (in the typ...
2012 Sep 06
0
[LLVMdev] Preferred alignment of globals > 16bytes
...ecently noticed that all globals bigger than 16 bytes are being 16 byte aligned by LLVM (assuming there isn't an explicitly requested alignment). I'd really rather avoid this, at least for the XCore backend. I tracked this down to the following code in TargetData.cpp: > > if (GV->hasInitializer() && GVAlignment == 0) { > if (Alignment < 16) { > // If the global is not external, see if it is large. If so, give it a > // larger alignment. > if (getTypeSizeInBits(ElemType) > 128) > Alignment = 16; // 16-byte alignment. > } >...
2011 Mar 09
0
[LLVMdev] TargetData::getPreferredAlignment(const GlobalVariable *GV) is strange ...
...*ElemType = GV->getType()->getElementType(); > unsigned Alignment = getPrefTypeAlignment(ElemType); > if (GV->getAlignment()> Alignment) > Alignment = GV->getAlignment(); > > ==================== confusion starts ======================== > if (GV->hasInitializer()) { > if (Alignment< 16) { > // If the global is not external, see if it is large. If so, give it a > // larger alignment. > if (getTypeSizeInBits(ElemType)> 128) > Alignment = 16; // 16-byte alignment. > } > } > ======...
2012 May 23
1
[LLVMdev] lli unable to resolve symbol _ZNKSt3__16locale9use_facetERNS0_2idE in bitcode
...t's > declared in the module. > > You could module tools/lli/lli.cpp to add a global: > > char *dummy_dso_handle = 0; > > and tie it to __dso_handle via. > > if (GlobalVariable *DSO = Mod->getGlobalVariable("__dso_handle")) > if (!DSO->hasInitializer()) > EE->updateGlobalMapping(DSO,&dummy_dso_handle); > > somewhere in main(), say after disabling lazy compilation. Entirely > untested though; we might need to give dummy_dso_handle a real value. this is already done in JIT.cpp, search for HAVE___DSO_HANDLE. Probably t...
2016 Aug 24
2
Change GlobalValue Type/Initializer
...The second problem that I have is with the function Verifier::visitGlobalVariable. Sometimes, the verifier tells me that the initializer type does not match the global variable type even when this is the case. >> >> This function will do the following check: >> >> if (GV.hasInitializer()) { >> Assert(GV.getInitializer()->getType() == GV.getType()->getElementType(), >> "Global variable initializer type does not match global " >> "variable type!", >> &GV); >> >> But I did not fin...
2012 May 22
5
[LLVMdev] lli unable to resolve symbol _ZNKSt3__16locale9use_facetERNS0_2idE in bitcode
Resending :(. Any pointers? tia On 5/21/2012 2:46 PM, Ashok Nalkund wrote: > On 5/21/2012 11:15 AM, Nick Lewycky wrote: >> Ashok Nalkund wrote: >>> Resending, any pointers? I demangled the symbol and it turns out to be: >>> std::__1::locale::use_facet(std::__1::locale::id&) const >> >> My guess is that you've got a .bc file produced on a mac using
2011 Mar 06
2
[LLVMdev] how to zero-init a global
Hi! I have a module containing a constant e.g. @input = global %0 zeroinitializer, align 16 when I copy the global into another module I use newGlobal->copyAttributesFrom(global); but the new module now has @input = external global %0, align 16 i.e. the zeroinitializer is missing. how do I set it or copy it from the other global? -Jochen
2011 Mar 06
0
[LLVMdev] how to zero-init a global
...wGlobal->copyAttributesFrom(global); > but the new module now has > > @input = external global %0, align 16 > > i.e. the zeroinitializer is missing. how do I set it or > copy it from the other global? The initializer doesn't count as an attribute, I guess. if (global->hasInitializer()) newGlobal->setInitializer(global->getInitializer()); Note that, as I mentioned in response to your earlier question, not all constants are safe to use in a different module. So simply copying the initializer may be unsafe... Note that linkage and constness don't seem to count eith...
2012 Sep 28
0
[LLVMdev] Fwd: Re: Getting Static Array Content
...com> Hi Ryan, On 28/09/2012 02:07, Ryan Taylor wrote: > I'm trying to get the values in a static global array. What is the > best way to go about doing this? > > Once I have the pointer (Ie GlobalVariable *GV = > dyn_cast<GlobalVariable>(itr))? Yes. Take a look at hasInitializer() and getInitializer() methods. The latter should give you a ConstantDataArray for arrays of simple types (dyn_cast here again to be sure). Ivan > > I basically just want to check for ConstantDataSequential and print > out the values. > > Thanks. > > > _________________...
2012 Sep 28
0
[LLVMdev] Getting Static Array Content
...gt; On 28/09/2012 02:07, Ryan Taylor wrote: > > I'm trying to get the values in a static global array. What is the best > way to go about doing this? > > Once I have the pointer (Ie GlobalVariable *GV = > dyn_cast<GlobalVariable>(itr))? > > > Yes. Take a look at hasInitializer() and getInitializer() methods. The > latter should give you a ConstantDataArray for arrays of simple types > (dyn_cast here again to be sure). > > Ivan > > > I basically just want to check for ConstantDataSequential and print out > the values. > > Thanks. > > &g...
2018 Mar 21
1
How to read String value of GlobalVariable?
Hi I have IR Code like ... @path = private constant [6xi8] c"abcde\00" ... --- Code from Pass --- GlobalVariable * GVPath = .... // contains @path I want to convert "abcde" to StringRef. Can you help me with GlobalVariable API? GlobalVariable::getInitializer() --> Constant* // How to get exact value äbcde from here? ~mahesh -------------- next part --------------
2011 Mar 09
1
[LLVMdev] TargetData::getPreferredAlignment(const GlobalVariable *GV) is strange ...
...etType()->getElementType(); >> unsigned Alignment = getPrefTypeAlignment(ElemType); >> if (GV->getAlignment()> Alignment) >> Alignment = GV->getAlignment(); >> >> ==================== confusion starts ======================== >> if (GV->hasInitializer()) { >> if (Alignment< 16) { >> // If the global is not external, see if it is large. If so, give it a >> // larger alignment. >> if (getTypeSizeInBits(ElemType)> 128) >> Alignment = 16; // 16-byte alignment. >> } &gt...
2004 Jun 18
1
[LLVMdev] Linkages handling
Hello, looking at Printer::doFinalization, I have some question about support of the different linkages. Here's a table of how that method handles the possible combinations: Initialized Null Internal .data, local .data, .comm, .local External .data, .globl .bss, .globl,
2015 Jun 08
2
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...runOnModule(Module &M) { + bool Changed = false; + + // Drop initializers of available externally global variables. + 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++; + } + + // Drop the bodies of available externally functions....
2017 May 22
2
DebugInfo, Metadata usage
...{ llvm::outs() << "Encoding : " << Encoding.str() << "\n"; } } } llvm::outs() << "\n\nPrint All Strings Declarations: \n"; for(GlobalVariable& GV : M->globals()) { if(!GV.hasInitializer()) continue; if(ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(GV.getInitializer())) { llvm::outs() << "GVName: " << GV.getName() << "\n"; llvm::outs() << "\tRawDataValues : " <&...
2015 Jun 08
4
[LLVMdev] Removing AvailableExternal values in GlobalDCE (was Re: RFC: ThinLTO Impementation Plan)
...ss()); > + } > > + // Drop initializers of available externally global variables. > + 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 n...
2012 Sep 07
2
[LLVMdev] Preferred alignment of globals > 16bytes
...noticed that all globals bigger than 16 bytes are being 16 byte aligned by LLVM (assuming there isn't an explicitly requested alignment). I'd really rather avoid this, at least for the XCore backend. I tracked this down to the following code in TargetData.cpp: >> >> if (GV->hasInitializer() && GVAlignment == 0) { >> if (Alignment < 16) { >> // If the global is not external, see if it is large. If so, give it a >> // larger alignment. >> if (getTypeSizeInBits(ElemType) > 128) >> Alignment = 16; // 16-byte a...