LLVM: include/llvm/CGData/CodeGenData.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_CGDATA_CODEGENDATA_H

15#define LLVM_CGDATA_CODEGENDATA_H

16

29#include

30

31namespace llvm {

32

34#define CG_DATA_SECT_ENTRY(Kind, SectNameCommon, SectNameCoff, Prefix) Kind,

36};

37

40 bool AddSegmentInfo = true);

41

50

62

66

68public:

70 : Err(Err), Msg(ErrStr.str()) {

72 }

73

74 std::string message() const override;

75

77

81

83 const std::string &getMessage() const { return Msg; }

84

85

86

87

88 static std::pair<cgdata_error, std::string> take(Error E) {

90 std::string Msg;

93 Err = IPE.get();

95 });

96 return {Err, Msg};

97 }

98

99 static char ID;

100

101private:

103 std::string Msg;

104};

105

111

112class CodeGenData {

113

114 std::unique_ptr PublishedHashTree;

115

116 std::unique_ptr PublishedStableFunctionMap;

117

118

119

120 bool EmitCGData;

121

122

123

124

125

126 static std::unique_ptr Instance;

127 static std::once_flag OnceFlag;

128

129 CodeGenData() = default;

130

131public:

133

135

136

138 return PublishedHashTree && !PublishedHashTree->empty();

139 }

141 return PublishedStableFunctionMap && !PublishedStableFunctionMap->empty();

142 }

143

144

145

147 return PublishedHashTree.get();

148 }

150 return PublishedStableFunctionMap.get();

151 }

152

153

155

156

158 PublishedHashTree = std::move(HashTree);

159

160 EmitCGData = false;

161 }

162 void

164 PublishedStableFunctionMap = std::move(FunctionMap);

165

166 EmitCGData = false;

167 }

168};

169

171

175

179

183

187

189

190inline void

194

195inline void

199

201

203

205

207

209

211 const Twine &CachePrefix)

214 return std::make_unique(

215 std::make_unique<raw_svector_ostream>(Outputs[Task]));

216 };

217

218 if (OrigCache.isValid()) {

219 auto CGCacheOrErr =

220 localCache("ThinLTO", CachePrefix, OrigCache.getCacheDirectoryPath(),

221 [&](size_t Task, const Twine &ModuleName,

222 std::unique_ptr MB) {

223 Files[Task] = std::move(MB);

224 });

225 if (Error Err = CGCacheOrErr.takeError())

227 Cache = std::move(*CGCacheOrErr);

228 }

229 }

231

232

233 std::unique_ptr<SmallVector> getResult() {

234 unsigned NumOutputs = Outputs.size();

235 auto Result = std::make_unique<SmallVector>(NumOutputs);

236 for (unsigned I = 0; I < NumOutputs; ++I)

238 (*Result)[I] = Files[I]->getBuffer();

239 else

241 return Result;

242 }

243};

244

245

246

247

248

249LLVM_ABI void saveModuleForTwoRounds(const Module &TheModule, unsigned Task,

251

252

253

254

255

256

257

258LLVM_ABI std::unique_ptr

259loadModuleForTwoRounds(BitcodeModule &OrigModule, unsigned Task,

261

262

263

264

267

270

271}

272

274

275

276

278

280

281

283

285

286

288

289

292};

294

301

302

303

304

305

306

308};

309

310}

311

312}

313

314#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

#define CG_DATA_INDEX_VERSION

Module.h This file contains the declarations for the Module class.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Represents a module in a bitcode file.

const std::string & getMessage() const

Definition CodeGenData.h:83

std::error_code convertToErrorCode() const override

Convert this error to a std::error_code.

Definition CodeGenData.h:78

static std::pair< cgdata_error, std::string > take(Error E)

Consume an Error and return the raw enum value contained within it, and the optional error message.

Definition CodeGenData.h:88

static char ID

Definition CodeGenData.h:99

std::string message() const override

Return the error message as a string.

void log(raw_ostream &OS) const override

Print an error message to an output stream.

Definition CodeGenData.h:76

CGDataError(cgdata_error Err, const Twine &ErrStr=Twine())

Definition CodeGenData.h:69

cgdata_error get() const

Definition CodeGenData.h:82

bool hasStableFunctionMap()

Definition CodeGenData.h:140

const StableFunctionMap * getStableFunctionMap()

Definition CodeGenData.h:149

bool emitCGData()

Returns true if we should write codegen data.

Definition CodeGenData.h:154

void publishOutlinedHashTree(std::unique_ptr< OutlinedHashTree > HashTree)

Publish the (globally) merged or read outlined hash tree.

Definition CodeGenData.h:157

bool hasOutlinedHashTree()

Returns true if we have a valid outlined hash tree.

Definition CodeGenData.h:137

const OutlinedHashTree * getOutlinedHashTree()

Returns the outlined hash tree.

Definition CodeGenData.h:146

void publishStableFunctionMap(std::unique_ptr< StableFunctionMap > FunctionMap)

Definition CodeGenData.h:163

static LLVM_ABI CodeGenData & getInstance()

Base class for user error types.

Lightweight error class with error context and mandatory checking.

Tagged union holding either a T or a Error.

This is an important class for using LLVM in a threaded context.

A Module instance is used to store all the information related to an LLVM module.

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

This class implements an extremely fast bulk output stream that can only output to a stream.

Definition CodeGenData.h:273

const uint64_t Version

Definition CodeGenData.h:293

CGDataVersion

Definition CodeGenData.h:279

@ Version2

Definition CodeGenData.h:284

@ CurrentVersion

Definition CodeGenData.h:291

@ Version3

Definition CodeGenData.h:287

@ Version1

Definition CodeGenData.h:282

@ Version4

Definition CodeGenData.h:290

const uint64_t Magic

Definition CodeGenData.h:277

Definition CodeGenData.h:170

void publishOutlinedHashTree(std::unique_ptr< OutlinedHashTree > HashTree)

Definition CodeGenData.h:191

bool hasOutlinedHashTree()

Definition CodeGenData.h:172

bool hasStableFunctionMap()

Definition CodeGenData.h:176

const OutlinedHashTree * getOutlinedHashTree()

Definition CodeGenData.h:180

void publishStableFunctionMap(std::unique_ptr< StableFunctionMap > FunctionMap)

Definition CodeGenData.h:196

bool emitCGData()

Definition CodeGenData.h:188

const StableFunctionMap * getStableFunctionMap()

Definition CodeGenData.h:184

This is an optimization pass for GlobalISel generic memory operations.

CGDataKind

Definition CodeGenData.h:42

@ StableFunctionMergingMap

Definition CodeGenData.h:47

@ Unknown

Definition CodeGenData.h:43

@ FunctionOutlinedHashTree

Definition CodeGenData.h:45

CGDataMode

Definition CodeGenData.h:106

@ Read

Definition CodeGenData.h:108

@ Write

Definition CodeGenData.h:109

std::error_code make_error_code(BitcodeError E)

void handleAllErrors(Error E, HandlerTs &&... Handlers)

Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...

cgdata_error

Definition CodeGenData.h:53

@ success

Definition CodeGenData.h:54

@ unsupported_version

Definition CodeGenData.h:60

@ eof

Definition CodeGenData.h:55

@ bad_magic

Definition CodeGenData.h:56

@ malformed

Definition CodeGenData.h:59

@ empty_cgdata

Definition CodeGenData.h:58

@ bad_header

Definition CodeGenData.h:57

@ None

Definition CodeGenData.h:107

LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)

LLVM_ABI const std::error_category & cgdata_category()

@ LLVM_MARK_AS_BITMASK_ENUM

CGDataSectKind

Definition CodeGenData.h:33

LogicalResult success(bool IsSuccess=true)

Utility function to generate a LogicalResult.

std::function< Expected< std::unique_ptr< CachedFileStream > >( unsigned Task, const Twine &ModuleName)> AddStreamFn

This type defines the callback to add a file that is generated on the fly.

LLVM_ABI std::string getCodeGenDataSectionName(CGDataSectKind CGSK, Triple::ObjectFormatType OF, bool AddSegmentInfo=true)

This type represents a file cache system that manages caching of files.

SmallVector< SmallString< 0 > > Outputs

Backing buffer for serialized data stream.

Definition CodeGenData.h:202

FileCache Cache

Cache mechanism for storing data.

Definition CodeGenData.h:208

SmallVector< std::unique_ptr< MemoryBuffer > > Files

Backing buffer for cached data.

Definition CodeGenData.h:206

std::unique_ptr< SmallVector< StringRef > > getResult()

Retrieve results from either the cache or the stream.

Definition CodeGenData.h:233

AddStreamFn AddStream

Callback function to add serialized data to the stream.

Definition CodeGenData.h:204

StreamCacheData(unsigned Size, const FileCache &OrigCache, const Twine &CachePrefix)

Definition CodeGenData.h:210