Liu Xin
2013-Dec-17 09:42 UTC
[LLVMdev] llvmContext::removeModule doesn't remove NamedStructTypes
Hi, LLVM community, I found an issue in my using scenario. We deliberately parse a bitcode file twice. It contains a named struct type. eg. %struct.cmd = type { float, float, float, float, float, i32 }. In the second module->dump, %struct.cmd becomes %struct.cmd0. my code is simplified like this. int main() { llvm::LLVMContext &llvmCtx = llvm::getGlobalContext(); string ErrMsg; string filename = "wrapper.bc"; llvm::OwningPtr<llvm::MemoryBuffer> File; if (llvm::MemoryBuffer::getFileOrSTDIN(filename, File)) { assert(0); } llvm::MemoryBuffer * buffer = File.take(); { llvm::OwningPtr<llvm::Module> module(llvm::ParseBitcodeFile(buffer, llvmCtx, &ErrMsg)); module->dump(); } { llvm::OwningPtr<llvm::Module> module(llvm::ParseBitcodeFile(buffer, llvmCtx, &ErrMsg)); module->dump(); } } with smart pointer, the 1st module will be deleted and call removeModule for the context. The implementation of removeModule is quite simple. It just removes the PtrSet. pImpl->OwnedModules.erase(M); It doesn't touch LLVMContextImpl's NamedStructTypes. As a result, 'struct.cmd' is still in the symbol table even the module has destroyed. In second ParseBitCodeFile, StructType::setName will introduce struct.cmd0 due to conflict. should we do thorough cleanup for the method removeModule? or why does llvm retain NamedStructTypes? thanks, --lx -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131217/e71ea5f2/attachment.html>
Reasonably Related Threads
- [LLVMdev] Lack of use of LLVMContextImpl::NamedStructTypes
- [LLVMdev] Lack of use of LLVMContextImpl::NamedStructTypes
- [LLVMdev] Lack of use of LLVMContextImpl::NamedStructTypes
- [LLVMdev] Lack of use of LLVMContextImpl::NamedStructTypes
- [LLVMdev] SmallPtrSet patch for MCJIT