llvm.org GIT mirror llvm / 0b29dea
LTO: Add API to choose whether to embed uselists Reverse libLTO's default behaviour for preserving use-list order in bitcode, and add API for controlling it. The default setting is now `false` (don't preserve them), which is consistent with `clang`'s default behaviour. Users of libLTO should call `lto_codegen_should_embed_uselists(CG,true)` prior to calling `lto_codegen_write_merged_modules()` whenever the output file isn't part of the production workflow in order to reproduce results with subsequent calls to `llc`. (I haven't added tests since `llvm-lto` (the test tool for LTO) doesn't support bitcode output, and even if it did: there isn't actually a good way to test whether a tool has passed the flag. If the order is already "natural" (if the order will already round-trip) then no use-list directives are emitted at all. At some point I'll circle back to add tests to `llvm-as` (etc.) that they actually respect the flag, at which point I can somehow add a test here as well.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235943 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 4 years ago
4 changed file(s) with 21 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7979 void setOptLevel(unsigned optLevel) { OptLevel = optLevel; }
8080
8181 void setShouldInternalize(bool Value) { ShouldInternalize = Value; }
82 void setShouldEmbedUselists(bool Value) { ShouldEmbedUselists = Value; }
8283
8384 void addMustPreserveSymbol(const char *sym) { MustPreserveSymbols[sym] = 1; }
8485
175176 void *DiagContext = nullptr;
176177 LTOModule *OwnedModule = nullptr;
177178 bool ShouldInternalize = true;
179 bool ShouldEmbedUselists = false;
178180 };
179181 }
180182 #endif
3939 * @{
4040 */
4141
42 #define LTO_API_VERSION 14
42 #define LTO_API_VERSION 15
4343
4444 /**
4545 * \since prior to LTO_API_VERSION=3
557557 lto_codegen_set_should_internalize(lto_code_gen_t cg,
558558 lto_bool_t ShouldInternalize);
559559
560 /**
561 * \brief Set whether to embed uselists in bitcode.
562 *
563 * Sets whether \a lto_codegen_write_merged_modules() should embed uselists in
564 * output bitcode. This should be turned on for all -save-temps output.
565 *
566 * \since LTO_API_VERSION=15
567 */
568 extern void
569 lto_codegen_set_should_embed_uselists(lto_code_gen_t cg,
570 lto_bool_t ShouldEmbedUselists);
571
560572 #ifdef __cplusplus
561573 }
562574 #endif
201201 }
202202
203203 // write bitcode to it
204 WriteBitcodeToFile(IRLinker.getModule(), Out.os(),
205 /* ShouldPreserveUseListOrder */ true);
204 WriteBitcodeToFile(IRLinker.getModule(), Out.os(), ShouldEmbedUselists);
206205 Out.os().close();
207206
208207 if (Out.os().has_error()) {
337337 bool ShouldInternalize) {
338338 unwrap(cg)->setShouldInternalize(ShouldInternalize);
339339 }
340
341 void lto_codegen_set_should_embed_uselists(lto_code_gen_t cg,
342 lto_bool_t ShouldEmbedUselists) {
343 unwrap(cg)->setShouldEmbedUselists(ShouldEmbedUselists);
344 }