Commit 75623f48 authored by Jaikrishnan Menon's avatar Jaikrishnan Menon

CPU: Minor codegen cleanup

Remove commented-out code and predicate debuginfo generation
parent 92430c2e
...@@ -68,18 +68,12 @@ static std::string GetExecutablePath(const char* Argv0) ...@@ -68,18 +68,12 @@ static std::string GetExecutablePath(const char* Argv0)
execution_state::execution_state() execution_state::execution_state()
: m_execution_engine{nullptr} : m_execution_engine{nullptr}
, pch_enabled(false) , pch_enabled(false)
, debuginfo_enabled(false)
{ {
} }
execution_state::~execution_state() execution_state::~execution_state()
{ {
// /// Take the LLVM context used by this action.
// llvm::LLVMContext *takeLLVMContext();
// if (m_execution_engine)
// {
// m_execution_engine->runStaticConstructorsDestructors(true);
// }
} }
std::unique_ptr<llvm::Module> execution_state::compile(const string& source, const string& name) std::unique_ptr<llvm::Module> execution_state::compile(const string& source, const string& name)
...@@ -146,10 +140,12 @@ std::unique_ptr<llvm::Module> execution_state::compile(const string& source, con ...@@ -146,10 +140,12 @@ std::unique_ptr<llvm::Module> execution_state::compile(const string& source, con
LO->WChar = 1; LO->WChar = 1;
LO->RTTI = 1; LO->RTTI = 1;
// CodeGen options if (debuginfo_enabled)
auto& CGO = Clang->getInvocation().getCodeGenOpts(); {
// TODO: Debuginfo inclusion should be predicated // CodeGen options
CGO.setDebugInfo(codegenoptions::FullDebugInfo); auto& CGO = Clang->getInvocation().getCodeGenOpts();
CGO.setDebugInfo(codegenoptions::FullDebugInfo);
}
if (pch_enabled) if (pch_enabled)
{ {
...@@ -165,8 +161,6 @@ std::unique_ptr<llvm::Module> execution_state::compile(const string& source, con ...@@ -165,8 +161,6 @@ std::unique_ptr<llvm::Module> execution_state::compile(const string& source, con
Clang->getInvocation().getPreprocessorOpts().addRemappedFile(name, buffer.get()); Clang->getInvocation().getPreprocessorOpts().addRemappedFile(name, buffer.get());
// Create and execute action // Create and execute action
// CodeGenAction *compilerAction = new EmitLLVMOnlyAction();
// CodeGenAction* compilerAction = new EmitAssemblyAction();
CodeGenAction* compilerAction = new EmitCodeGenOnlyAction(); CodeGenAction* compilerAction = new EmitCodeGenOnlyAction();
Clang->ExecuteAction(*compilerAction); Clang->ExecuteAction(*compilerAction);
...@@ -181,13 +175,10 @@ bool execution_state::add_module(std::unique_ptr<llvm::Module>& module) ...@@ -181,13 +175,10 @@ bool execution_state::add_module(std::unique_ptr<llvm::Module>& module)
{ {
if (!m_execution_engine) if (!m_execution_engine)
{ {
// auto mm = unique_ptr<RTDyldMemoryManager>(new method_resolver(this));
m_execution_engine = llvm::EngineBuilder(move(module)) m_execution_engine = llvm::EngineBuilder(move(module))
.setEngineKind(llvm::EngineKind::JIT) .setEngineKind(llvm::EngineKind::JIT)
.setOptLevel(llvm::CodeGenOpt::Aggressive) .setOptLevel(llvm::CodeGenOpt::Aggressive)
.setErrorStr(&jit_error) .setErrorStr(&jit_error)
// .setUseMCJIT(true)
// .setMCJITMemoryManager(std::move(mm))
.create(); .create();
if (!m_execution_engine) if (!m_execution_engine)
......
...@@ -47,6 +47,9 @@ public: ...@@ -47,6 +47,9 @@ public:
void enable_pch() { pch_enabled = true; } void enable_pch() { pch_enabled = true; }
void disable_pch() { pch_enabled = false; } void disable_pch() { pch_enabled = false; }
void enable_debuginfo() { debuginfo_enabled = true; }
void disable_debuginfo() { debuginfo_enabled = false; }
std::unique_ptr<llvm::Module> compile(const std::string& source, const std::string& name = ""); std::unique_ptr<llvm::Module> compile(const std::string& source, const std::string& name = "");
bool add_module(std::unique_ptr<llvm::Module>&); bool add_module(std::unique_ptr<llvm::Module>&);
...@@ -65,20 +68,11 @@ private: ...@@ -65,20 +68,11 @@ private:
llvm::ExecutionEngine* m_execution_engine; llvm::ExecutionEngine* m_execution_engine;
std::string jit_error; std::string jit_error;
bool pch_enabled; bool pch_enabled;
bool debuginfo_enabled;
template <typename signature> template <typename signature>
std::function<signature> f_cast(void* f) std::function<signature> f_cast(void* f)
{ {
return static_cast<signature*>(reinterpret_cast<signature*>(f)); return static_cast<signature*>(reinterpret_cast<signature*>(f));
} }
// class method_resolver : public llvm::RTDyldMemoryManager
// {
// public:
// method_resolver(compiler* m);
// virtual uint64_t getSymbolAddress(const std::string &name) override;
// private:
// compiler* m_Compiler;
// };
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment