Really sorry if this is a dumb/n00b question!
I’m trying to debug this code…
void addPointerParameter(llvm::Type *storageType) {
ParamIRTypes.push_back(storageType->getPointerTo(storageType->getPointerAddressSpace()));
}
…it’s currently crashing when passed this type…
(lldb) e storageType->dump()
%T4main5Stats33_19C37605F80094DED36B2D41C8D0773FLLV = type <{ %Ts5UInt8V, %Ts5UInt8V }>
( %Ts5UInt8V
is itself a simple struct containing an i8
)
I would expect getPointerAddressSpace()
to always work for all types and I sort of assumed it would read the datalayout then return the appropriate address space.
The code called seems to be from llvm/include/llvm/IR/DerivedTypes.h
…
unsigned Type::getPointerAddressSpace() const {
return cast<PointerType>(getScalarType())->getAddressSpace();
}
In this case, getScalarType()
leaves the type unchanged and cast<PointerType>
crashes, presumably because this is a struct, not a pointer?
I’m wondering if I’m holding this wrong, or just have old (20 month old) code or (most likely) if I’ve fundamentally misunderstood something!?
Thanks for any advice or help anyone can give.
Carl