search for: getstructlayout

Displaying 20 results from an estimated 21 matches for "getstructlayout".

2010 Nov 11
1
[LLVMdev] named types with self-references
...e this definition without errors. >> >> JIT executes '%0 = alloca %rt' as allocating a memory with size 0. >> Because the llvm::TargetData::getTypeAllocSize accually returns 0 in >> this case. The function that calculates %rt's size is by the >> TargetData::getStructLayout, which calculates the a layout of %rt. It >> can only returns 0 when the element type %rt is not defined yet, since >> the result is infinite otherwise. >> >> Is %rt = {%rt} still a valid or useful type for LLVM IR? > > No, that's not (or shouldn't be) a valid...
2010 Nov 11
2
[LLVMdev] named types with self-references
...named type ? %rt = {%rt} llvm-as can parse this definition without errors. JIT executes '%0 = alloca %rt' as allocating a memory with size 0. Because the llvm::TargetData::getTypeAllocSize accually returns 0 in this case. The function that calculates %rt's size is by the TargetData::getStructLayout, which calculates the a layout of %rt. It can only returns 0 when the element type %rt is not defined yet, since the result is infinite otherwise. Is %rt = {%rt} still a valid or useful type for LLVM IR? %rt = {%rt*}, { \2 }* or even \1* are definitely good types to represent recursive data types....
2010 Nov 11
0
[LLVMdev] named types with self-references
...t; llvm-as can parse this definition without errors. > > JIT executes '%0 = alloca %rt' as allocating a memory with size 0. > Because the llvm::TargetData::getTypeAllocSize accually returns 0 in > this case. The function that calculates %rt's size is by the > TargetData::getStructLayout, which calculates the a layout of %rt. It > can only returns 0 when the element type %rt is not defined yet, since > the result is infinite otherwise. > > Is %rt = {%rt} still a valid or useful type for LLVM IR? No, that's not (or shouldn't be) a valid type. In this case, zer...
2018 Apr 18
4
A struct {i8,i64} has size == 12, clang says size 16
I'm creating a struct of `{i8,i64}` and `DataLayout::getTypeAllocSize` is returning `12`. `getStructLayout` also gives an `4` offset for the second element. The native ABI, and clang, for the same type are producing a size of 16, with an alignment of 8, for the second element. This is for the system triple "x86_64-linux-gnu" What could be causing this difference in alignment and how can I f...
2018 Apr 18
0
A struct {i8, i64} has size == 12, clang says size 16
...y not match clang's for x86_64-linux. What does it say about the alignment of i64? On Wed, Apr 18, 2018 at 12:05 PM edA-qa mort-ora-y via llvm-dev < llvm-dev at lists.llvm.org> wrote: > I'm creating a struct of `{i8,i64}` and `DataLayout::getTypeAllocSize` > is returning `12`. `getStructLayout` also gives an `4` offset for the > second element. > The native ABI, and clang, for the same type are producing a size of 16, > with an alignment of 8, for the second element. > This is for the system triple "x86_64-linux-gnu" > What could be causing this difference in...
2010 Apr 23
2
[LLVMdev] variable sized array
Hi all, just a quick question, in llvm::TargetData, uint64_t MemberOffsets[1]; // variable sized array! MemberOffsets has two elements, why it's variable sized ? yuanfang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100423/6e0d57a5/attachment.html>
2010 Apr 23
0
[LLVMdev] variable sized array
Hi Yuanfang, > just a quick question, in llvm::TargetData, > > uint64_t MemberOffsets[1]; // variable sized array! > > MemberOffsets has two elements, why it's variable sized ? when a StructLayout object is allocated (in TargetData::getStructLayout), extra memory is allocated, more than that given by the size of the type. The extra memory is interpreted as being part of the MemberOffsets array, and is used for storing additional member offsets beyond the first one. This kind of trick generates warnings with gcc-4.5. Maybe it can be done bet...
2012 Mar 22
1
[LLVMdev] StructLayout getSizeInBits()
LLVMers, I have a const StructType *StTy where I call TargetData->getStructLayout(const_cast<StructType*>(StTy))->getSizeInBits() but it continues to return 64 regardless of the actual size of the struct? I want the size of the structure in bits, including alignment padding for offset calculations, is this not the right function call? Thanks. -------------- next part -...
2010 Oct 26
2
[LLVMdev] StructType member offset
Hi, how can i correctly calculate the size of a member of a struct (including alignment etc)? This doesn't work : const StructType *STy = cast<StructType>(Ty); for (StructType::element_iterator I = STy->element_begin(), E = STy->element_end(); I != E; ++I) { usigned size =I->get()->getScalarSizeInBits(); //often
2018 Apr 18
2
A struct {i8, i64} has size == 12, clang says size 16
...x86_64-linux. What > does it say about the alignment of i64? > On Wed, Apr 18, 2018 at 12:05 PM edA-qa mort-ora-y via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> I'm creating a struct of `{i8,i64}` and `DataLayout::getTypeAllocSize` >> is returning `12`. `getStructLayout` also gives an `4` offset for the >> second element. >> The native ABI, and clang, for the same type are producing a size of 16, >> with an alignment of 8, for the second element. >> This is for the system triple "x86_64-linux-gnu" >> What could be causing th...
2004 Dec 03
1
[Fwd: [LLVMdev] GetElementPtr for packed types and VS build]
...ed AlignedSize = (Size + Alignment - 1)/Alignment*Alignment; > + Size = AlignedSize*PTy->getNumElements(); > + return; > + } > case Type::StructTyID: { > // Get the layout annotation... which is lazily created on demand. > const StructLayout *Layout = TD->getStructLayout(cast<StructType>(Ty)); > Index: lib/VMCore/Type.cpp > =================================================================== > RCS file: /var/cvs/llvm/llvm/lib/VMCore/Type.cpp,v > retrieving revision 1.119 > diff -u -r1.119 Type.cpp > --- lib/VMCore/Type.cpp 19 Nov 2004 16:39:4...
2018 Apr 19
0
A struct {i8, i64} has size == 12, clang says size 16
...does it say about the alignment of i64? > > On Wed, Apr 18, 2018 at 12:05 PM edA-qa mort-ora-y via llvm-dev < > > llvm-dev at lists.llvm.org> wrote: > > > >> I'm creating a struct of `{i8,i64}` and `DataLayout::getTypeAllocSize` > >> is returning `12`. `getStructLayout` also gives an `4` offset for the > >> second element. > >> The native ABI, and clang, for the same type are producing a size of 16, > >> with an alignment of 8, for the second element. > >> This is for the system triple "x86_64-linux-gnu" > >>...
2010 Nov 03
0
[LLVMdev] StructType member offset
.... There's even a helper for doing this: ConstantExpr:getOffsetOf Ciao, Duncan. > > - Mark > > On Wed, Oct 27, 2010 at 2:25 AM, Duncan Sands <baldrick at free.fr > <mailto:baldrick at free.fr>> wrote: > > Hi Alex, > > I think you are looking for getStructLayout from TargetData (the > StructLayout type is also defined in TargetData.h). > > Ciao, > > Duncan. > > > how can i correctly calculate the size of a member of a struct > > (including alignment etc)? > > This doesn't work : > &...
2020 Nov 13
0
Get the layout offset of an aggregate type's leave types
Hi, I have an aggregate type like {i32, {i8*, i16}, [2xi8], ... }, [2 x {i8*, i32}], and wanted to get the offset of a leaf type from the beginning of the aggregate type at compilation time. DataLayout::getStructLayout returns the layout of the current level of a struct. * Do we have any API to get the layout for all leave types for sub-struct? * How to get the offset of each element of an Array type? Thank you, j -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.ll...
2010 Mar 15
0
[LLVMdev] [patch] Writing ConstantUnions
...Data.cpp =================================================================== --- lib/Target/TargetData.cpp (revision 98552) +++ lib/Target/TargetData.cpp (working copy) @@ -460,6 +460,15 @@ case Type::StructTyID: // Get the layout annotation... which is lazily created on demand. return getStructLayout(cast<StructType>(Ty))->getSizeInBits(); + case Type::UnionTyID: { + const UnionType *UnTy = cast<UnionType>(Ty); + uint64_t Size = 0; + for (UnionType::element_iterator i = UnTy->element_begin(), + e = UnTy->element_end(); i != e; ++i) { + Size = std:...
2011 Feb 04
3
[LLVMdev] Data layout of structs
Dear all, I'm currently working on the automated program analysis tool AProVE (http://aprove.informatik.rwth-aachen.de/) and would like to use LLVM for analysis of C programs. I have the following example C program dealing with simple lists of integers: ------------ start C example ------------- #include<stdlib.h> struct list_el { int val; struct list_el * next; }; typedef
2010 Mar 15
3
[LLVMdev] [patch] Writing ConstantUnions
Hello, I noticed a bit of a gap in the current code for unions: a ConstantUnion cannot be written out to .ll. Hopefully I'm not stepping on Talin's toes by posting this, it's a fairly straightforward adaptation of the code for structs just above. Tim. -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. --------------
2009 Feb 19
2
[LLVMdev] please review this fix for PR3510
Please review this patch for PR3510 (and <rdar://problem/6564697>). The bug is a failure to handle a "hole" inside an initialized structure, where the hole may be induced by a designated initializer or by alignment: http://llvm.org/bugs/show_bug.cgi?id=3510 The original code was greatly simplified by using FieldNo to index the LLVM fields and the initializer in
2009 Jan 09
2
[LLVMdev] RFC: Store alignment should be LValue alignment, not source alignment
...E || TREE_CODE(DECL_CONTEXT(FieldDecl)) == UNION_TYPE || TREE_CODE(DECL_CONTEXT(FieldDecl)) == QUAL_UNION_TYPE)); @@ -6064,7 +6100,9 @@ LValue TreeToLLVM::EmitLV_COMPONENT_REF( // the offset from BitStart. if (MemberIndex) { const StructLayout *SL = TD.getStructLayout(cast<StructType>(StructTy)); - BitStart -= SL->getElementOffset(MemberIndex) * 8; + unsigned Offset = SL->getElementOffset(MemberIndex); + BitStart -= Offset * 8; + LVAlign = MinAlign(LVAlign, Offset); } // If the FIELD_DECL has an annotate attribute on...
2018 Nov 25
6
RFC: Modernizing our use of auto
I'm not advocating AAA. However this is a proposal for more modern thinking regarding the permissiveness of auto in LLVM codebases. Currently the rule on the use of auto is here: https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable It is quite strict. It allows the use of auto for * lambdas * iterators because they are long to type * casts to