llvm.org GIT mirror llvm / 4f4a190
Add some comment to LTOCodeGenerator class git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187761 91177308-0d34-0410-b5e6-96231b3b80d8 Shuxin Yang 7 years ago
1 changed file(s) with 44 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
77 //===----------------------------------------------------------------------===//
88 //
99 // This file declares the LTOCodeGenerator class.
10 //
11 // LTO compilation consists of three phases: Pre-IPO, IPO and Post-IPO.
12 //
13 // The Pre-IPO phase compiles source code into bitcode file. The resulting
14 // bitcode files, along with object files and libraries, will be fed to the
15 // linker to through the IPO and Post-IPO phases. By using obj-file extension,
16 // the resulting bitcode file disguises itself as an object file, and therefore
17 // obviates the need of writing a special set of the make-rules only for LTO
18 // compilation.
19 //
20 // The IPO phase perform inter-procedural analyses and optimizations, and
21 // the Post-IPO consists two sub-phases: intra-procedural scalar optimizations
22 // (SOPT), and intra-procedural target-dependent code generator (CG).
23 //
24 // As of this writing, we don't separate IPO and the Post-IPO SOPT. They
25 // are intermingled together, and are driven by a single pass manager (see
26 // PassManagerBuilder::populateLTOPassManager()).
27 //
28 // The "LTOCodeGenerator" is the driver for the IPO and Post-IPO stages.
29 // The "CodeGenerator" here is bit confusing. Don't confuse the "CodeGenerator"
30 // with the machine specific code generator.
1031 //
1132 //===----------------------------------------------------------------------===//
1233
4970 _mustPreserveSymbols[sym] = 1;
5071 }
5172
73 // To pass options to the driver and optimization passes. These options are
74 // not necessarily for debugging purpose (The function name is misleading).
75 // This function should be called before LTOCodeGenerator::compilexxx(),
76 // and LTOCodeGenerator::writeMergedModules().
77 //
78 void setCodeGenDebugOptions(const char *opts);
79
5280 bool writeMergedModules(const char *path, std::string &errMsg);
81
82 // Compile the merged module into a *single* object file; the path to object
83 // file is returned to the caller via argument "name". Return *FALSE* on
84 // *SUCCESS*, true otherwise.
85 //
86 // NOTE that it is up to the linker to remove the intermediate object file.
87 // Do not try to remove the object file in LTOCodeGenerator's destructor
88 // as we don't who (LTOCodeGenerator or the obj file) will last longer.
89 //
5390 bool compile_to_file(const char **name, std::string &errMsg);
91
92 // As with compile_to_file(), this function compiles the merged module into
93 // single object file. Instead of returning the object-file-path to the caller
94 // (linker), it brings the object to a buffer, and return the buffer to the
95 // caller. This function should delete intermediate object file once its content
96 // is brought to memory. Return NULL is the compilation was not successful.
97 //
5498 const void *compile(size_t *length, std::string &errMsg);
55 void setCodeGenDebugOptions(const char *opts);
5699
57100 private:
58101 void initializeLTOPasses();