mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
Change the name of a module to some hash (for caching)
This commit is contained in:
parent
bd85efa299
commit
2332595c9c
1 changed files with 7 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
|
@ -153,8 +154,13 @@ void Compiler::createBasicBlocks(bytes const& _bytecode)
|
||||||
|
|
||||||
std::unique_ptr<llvm::Module> Compiler::compile(bytes const& _bytecode)
|
std::unique_ptr<llvm::Module> Compiler::compile(bytes const& _bytecode)
|
||||||
{
|
{
|
||||||
|
// TODO: Better hash of code needed, probably SHA3
|
||||||
|
std::string code{reinterpret_cast<char const*>(_bytecode.data()), _bytecode.size()};
|
||||||
|
auto hash = std::hash<std::string>{}(code);
|
||||||
|
auto strHash = std::to_string(hash);
|
||||||
|
|
||||||
auto compilationStartTime = std::chrono::high_resolution_clock::now();
|
auto compilationStartTime = std::chrono::high_resolution_clock::now();
|
||||||
auto module = std::unique_ptr<llvm::Module>(new llvm::Module("main", m_builder.getContext()));
|
auto module = std::unique_ptr<llvm::Module>(new llvm::Module(strHash, m_builder.getContext()));
|
||||||
|
|
||||||
// Create main function
|
// Create main function
|
||||||
auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, Type::RuntimePtr, false);
|
auto mainFuncType = llvm::FunctionType::get(Type::MainReturn, Type::RuntimePtr, false);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue