[LLVMdev] Linking modules across contexts crashes
Yuri
yuri at rawbw.com
Thu Jun 4 13:47:01 PDT 2015
On 06/02/2015 13:05, Duncan P. N. Exon Smith wrote:
> If you want to work on a solution, I think a better approach would be
> adding API for one (or both) of:
>
> class Module {
> public:
> /// Move this module to the given context.
> void changeContext(LLVMContext &NewContext);
> };
>
> /// Remap the given module in a different context.
> std::unique_ptr<Module> remapModuleToContext(
> const Module &M, LLVMContext &NewContext);
While working on the patch, I have two questions:
1. How to find all constants in Module? Does this code find all of them,
or they are somewhere else too?
for (GlobalVariable &GV : globals()) {
if (auto C = static_cast<Constant*>(GV.Op<0>().get())) {
... C is Constant*
}
}
2. How to create an equivalent ConstantArray/ConstantStruct objects in
another context? ConstantArray::get(ArrayType *T, ArrayRef<Constant*>V)
creates it, and puts it into LLVMContextImpl::ArrayConstants.
ArrayConstants has the DenseMap ConstantUniqueMap::Map with
ConstantArray* as a key, but how to read back ArrayRef<Constant*>
ConstantArray was created with?
Yuri
More information about the llvm-dev
mailing list