Exemple #1
0
void ObjectCache::notifyObjectCompiled(llvm::Module const* _module, llvm::MemoryBufferRef _object)
{
	Guard g{x_cacheMutex};

	// Only in "on" and "write" mode
	if (g_mode != CacheMode::on && g_mode != CacheMode::write)
		return;

	// TODO: Disabled because is not thread-safe.
	// if (g_listener)
		// g_listener->stateChanged(ExecState::CacheWrite);

	auto&& id = _module->getModuleIdentifier();
	llvm::SmallString<256> cachePath{getVersionedCacheDir()};
	if (auto err = llvm::sys::fs::create_directories(cachePath))
	{
		DLOG(cache) << "Cannot create cache dir " << cachePath.str().str() << " (error: " << err.message() << "\n";
		return;
	}

	llvm::sys::path::append(cachePath, id);

	DLOG(cache) << id << ": write\n";
	std::error_code error;
	llvm::raw_fd_ostream cacheFile(cachePath, error, llvm::sys::fs::F_None);
	cacheFile << _object.getBuffer();
}
Exemple #2
0
void PystonObjectCache::notifyObjectCompiled(const llvm::Module* M, llvm::MemoryBufferRef Obj)
#endif
{
    RELEASE_ASSERT(module_identifier == M->getModuleIdentifier(), "");
    RELEASE_ASSERT(!hash_before_codegen.empty(), "");

    llvm::SmallString<128> cache_file = cache_dir;
    llvm::sys::path::append(cache_file, hash_before_codegen);
    if (!llvm::sys::fs::exists(cache_dir.str()) && llvm::sys::fs::create_directories(cache_dir.str()))
        return;

    CompressedFile::writeFile(cache_file, Obj.getBuffer());
}
StringRef
RawPCHContainerReader::ExtractPCH(llvm::MemoryBufferRef Buffer) const {
  return Buffer.getBuffer();
}