19
19
#include " llvm/ADT/StringSet.h"
20
20
#include " llvm/ADT/Triple.h"
21
21
#include " llvm/IR/ModuleSummaryIndex.h"
22
- #include " llvm/LTO/LTO.h"
23
22
#include " llvm/Support/CachePruning.h"
24
23
#include " llvm/Support/CodeGen.h"
25
24
#include " llvm/Support/MemoryBuffer.h"
@@ -32,6 +31,23 @@ class StringRef;
32
31
class LLVMContext ;
33
32
class TargetMachine ;
34
33
34
+ // / Wrapper around MemoryBufferRef, owning the identifier
35
+ class ThinLTOBuffer {
36
+ std::string OwnedIdentifier;
37
+ StringRef Buffer;
38
+
39
+ public:
40
+ ThinLTOBuffer (StringRef Buffer, StringRef Identifier)
41
+ : OwnedIdentifier(Identifier), Buffer(Buffer) {}
42
+
43
+ MemoryBufferRef getMemBuffer () const {
44
+ return MemoryBufferRef (Buffer,
45
+ {OwnedIdentifier.c_str (), OwnedIdentifier.size ()});
46
+ }
47
+ StringRef getBuffer () const { return Buffer; }
48
+ StringRef getBufferIdentifier () const { return OwnedIdentifier; }
49
+ };
50
+
35
51
// / Helper to gather options relevant to the target machine creation
36
52
struct TargetMachineBuilder {
37
53
Triple TheTriple;
@@ -251,36 +267,31 @@ class ThinLTOCodeGenerator {
251
267
* and additionally resolve weak and linkonce symbols.
252
268
* Index is updated to reflect linkage changes from weak resolution.
253
269
*/
254
- void promote (Module &Module, ModuleSummaryIndex &Index,
255
- const lto::InputFile &File);
270
+ void promote (Module &Module, ModuleSummaryIndex &Index);
256
271
257
272
/* *
258
273
* Compute and emit the imported files for module at \p ModulePath.
259
274
*/
260
275
void emitImports (Module &Module, StringRef OutputName,
261
- ModuleSummaryIndex &Index,
262
- const lto::InputFile &File);
276
+ ModuleSummaryIndex &Index);
263
277
264
278
/* *
265
279
* Perform cross-module importing for the module identified by
266
280
* ModuleIdentifier.
267
281
*/
268
- void crossModuleImport (Module &Module, ModuleSummaryIndex &Index,
269
- const lto::InputFile &File);
282
+ void crossModuleImport (Module &Module, ModuleSummaryIndex &Index);
270
283
271
284
/* *
272
285
* Compute the list of summaries needed for importing into module.
273
286
*/
274
287
void gatherImportedSummariesForModule (
275
288
Module &Module, ModuleSummaryIndex &Index,
276
- std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex,
277
- const lto::InputFile &File);
289
+ std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex);
278
290
279
291
/* *
280
292
* Perform internalization. Index is updated to reflect linkage changes.
281
293
*/
282
- void internalize (Module &Module, ModuleSummaryIndex &Index,
283
- const lto::InputFile &File);
294
+ void internalize (Module &Module, ModuleSummaryIndex &Index);
284
295
285
296
/* *
286
297
* Perform post-importing ThinLTO optimizations.
@@ -302,7 +313,7 @@ class ThinLTOCodeGenerator {
302
313
303
314
// / Vector holding the input buffers containing the bitcode modules to
304
315
// / process.
305
- std::vector<std::unique_ptr<lto::InputFile> > Modules;
316
+ std::vector<ThinLTOBuffer > Modules;
306
317
307
318
// / Set of symbols that need to be preserved outside of the set of bitcode
308
319
// / files.
0 commit comments