Skip to content

Commit

Permalink
fix: Fixed memory leak due to unused modules
Browse files Browse the repository at this point in the history
  • Loading branch information
alinalihassan committed Mar 10, 2022
1 parent a0088a9 commit 4d2282f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
7 changes: 0 additions & 7 deletions src/Backend/Codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ void Codegen::CompileModule(Span span, const std::string &filepath) {
Scope->insertSymbol(name, (Value *) &(*it).getFunction(), (*it).getFunctionType());
}

Modules.push_back(codegen->getModule());
} else {
std::string obj_file = fmt::format("tmp{}", ObjectFiles.size());
codegen->WriteToObjectFile(obj_file);
Expand Down Expand Up @@ -188,12 +187,6 @@ void Codegen::LinkObjectFile(const std::string &obj_filename) {
}

int Codegen::JIT() {
// Commented out for now, the linker seems to just copy the functions over to the main module
// for (auto &module: Modules) {
// auto jit_error = TheJIT->addModule(std::move(module));
// if (jit_error)
// throw CodegenError("JIT Error:\n{}");
// }
auto jit_error = TheJIT->addModule(ThreadSafeModule(std::move(TheModule), std::move(TheContext)));
if (jit_error)
throw CodegenError({}, "JIT Error:\n{}");
Expand Down
1 change: 0 additions & 1 deletion src/Backend/Codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace lesma {
std::stack<llvm::BasicBlock *> continueBlocks;
std::stack<std::vector<llvm::Value *>> deferStack;

std::vector<ThreadSafeModule> Modules;
std::vector<std::string> ObjectFiles;
llvm::Function *TopLevelFunc;
bool isBreak = false;
Expand Down

0 comments on commit 4d2282f

Please sign in to comment.