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
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