Andrew Kelley via llvm-dev
2018-Sep-16 15:17 UTC
[llvm-dev] how to determine abi alignment of function based on its type?
The following assertion is tripping when I do LLVMABIAlignmentOfType on a function type: #4 0x0000000005b67fc4 in llvm::DataLayout::getAlignment (this=0xa0bb960, Ty=0xa0bee58, abi_or_pref=true) at /home/andy/downloads/llvm_release_70/lib/IR/DataLayout.cpp:672 672 assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"); (gdb) p Ty->dump() void () Shouldn't this type be sized? Is this a bug? As a workaround, I have to assume that all functions are only 1-byte aligned, but that doesn't seem sound. Is it possible to find out the ABI alignment of a function? Regards, Andrew -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180916/ca329798/attachment.html>
Tim Northover via llvm-dev
2018-Sep-16 17:35 UTC
[llvm-dev] how to determine abi alignment of function based on its type?
Hi Andrew, On Sun, 16 Sep 2018 at 16:17, Andrew Kelley via llvm-dev <llvm-dev at lists.llvm.org> wrote:> (gdb) p Ty->dump() > void () > > Shouldn't this type be sized? Is this a bug?That's a function taking no parameters and returning void. Notably *not* a pointer to such a function. So it could have pretty much any size depending on the function body (well, if we actually modelled the size, which we don't).> As a workaround, I have to assume that all functions are only 1-byte aligned, but that doesn't seem sound.Minimum function alignment is specified in C++ via TargetLoweringBase (and hence TargetLowering). Cheers. Tim.