[llvm-dev] Alignment of GVMemoryBlocks
Alex Horn via llvm-dev
llvm-dev at lists.llvm.org
Wed Nov 7 15:55:04 PST 2018
Hello,
Is anyone familiar with the ExecutionEngine, particularly the handling of GVMemoryBlocks?
Line 114 in Create(GV,TD) is suspicious [1]:
static char *Create(const GlobalVariable *GV, const DataLayout& TD) {
Type *ElTy = GV->getValueType();
size_t GVSize = (size_t)TD.getTypeAllocSize(ElTy);
void *RawMemory = ::operator new(
alignTo(sizeof(GVMemoryBlock), TD.getPreferredAlignment(GV)) + GVSize);
new(RawMemory) GVMemoryBlock(GV);
return static_cast<char*>(RawMemory) + sizeof(GVMemoryBlock); // <— [1]
}
Example:
Suppose sizeof(GVMemoryBlock) == 3 bytes. Further, assume the preferred TD-alignment is on 4-byte boundaries. Finally, for sake of argument, assume RawMemory points to address 4. Then Create(GV, TD) returns 7, a non-aligned address with respect to the preferred TD-alignment.
Is this expected?
Many thanks for your time!
- Alex
[1] https://github.com/llvm-mirror/llvm/blob/91b6092209489b4790826efc66fce178a6ec7f46/lib/ExecutionEngine/ExecutionEngine.cpp#L114
PS
Also, if anyone happens to know, why is the empty ~GVMemoryBlock() destructor explicitly called in the deleted() callback? The last comment left there seems to indicate someone else before me was also puzzled by this :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181107/8e46b5cd/attachment.html>
More information about the llvm-dev
mailing list