Пример #1
0
    llvm::MemoryBuffer *BCCache::get( std::string const &key ) const
    {
      RC::ConstHandle<IO::Dir> subDir;
      std::string entry;
      subDirAndEntryFromKey( key, subDir, entry );

      llvm::OwningPtr<llvm::MemoryBuffer> buffer;
      llvm::error_code fileError =
        llvm::MemoryBuffer::getFileOrSTDIN( subDir->getFullFilePath( entry ), buffer );
      if ( !fileError )
        return buffer.take();
      return NULL;
    }
Пример #2
0
    void BCCache::put( std::string const &key, llvm::Module *module ) const
    {
      RC::ConstHandle<IO::Dir> subDir;
      std::string entry;
      subDirAndEntryFromKey( key, subDir, entry );

      std::string errors;
      llvm::raw_fd_ostream bcStream(
        subDir->getFullFilePath( entry ).c_str(),
        errors,
        llvm::raw_fd_ostream::F_Binary
      );

      llvm::WriteBitcodeToFile( module, bcStream );
      bcStream.flush();
    }