xref: /llvm-project-15.0.7/llvm/tools/lto/lto.cpp (revision 052d95a6)
1 //===-lto.cpp - LLVM Link Time Optimizer ----------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Link Time Optimization library. This library is
11 // intended to be used by linker to optimize code at link time.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "llvm-c/lto.h"
16 #include "llvm/ADT/STLExtras.h"
17 #include "llvm/Bitcode/BitcodeReader.h"
18 #include "llvm/CodeGen/CommandFlags.h"
19 #include "llvm/IR/DiagnosticInfo.h"
20 #include "llvm/IR/DiagnosticPrinter.h"
21 #include "llvm/IR/LLVMContext.h"
22 #include "llvm/LTO/legacy/LTOCodeGenerator.h"
23 #include "llvm/LTO/legacy/LTOModule.h"
24 #include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
25 #include "llvm/Support/MemoryBuffer.h"
26 #include "llvm/Support/Signals.h"
27 #include "llvm/Support/TargetSelect.h"
28 #include "llvm/Support/raw_ostream.h"
29 
30 // extra command-line flags needed for LTOCodeGenerator
31 static cl::opt<char>
32 OptLevel("O",
33          cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
34                   "(default = '-O2')"),
35          cl::Prefix,
36          cl::ZeroOrMore,
37          cl::init('2'));
38 
39 static cl::opt<bool>
40 DisableInline("disable-inlining", cl::init(false),
41   cl::desc("Do not run the inliner pass"));
42 
43 static cl::opt<bool>
44 DisableGVNLoadPRE("disable-gvn-loadpre", cl::init(false),
45   cl::desc("Do not run the GVN load PRE pass"));
46 
47 static cl::opt<bool>
48 DisableLTOVectorization("disable-lto-vectorization", cl::init(false),
49   cl::desc("Do not run loop or slp vectorization during LTO"));
50 
51 #ifdef NDEBUG
52 static bool VerifyByDefault = false;
53 #else
54 static bool VerifyByDefault = true;
55 #endif
56 
57 static cl::opt<bool> DisableVerify(
58     "disable-llvm-verifier", cl::init(!VerifyByDefault),
59     cl::desc("Don't run the LLVM verifier during the optimization pipeline"));
60 
61 // Holds most recent error string.
62 // *** Not thread safe ***
63 static std::string sLastErrorString;
64 
65 // Holds the initialization state of the LTO module.
66 // *** Not thread safe ***
67 static bool initialized = false;
68 
69 // Holds the command-line option parsing state of the LTO module.
70 static bool parsedOptions = false;
71 
72 static LLVMContext *LTOContext = nullptr;
73 
74 static void diagnosticHandler(const DiagnosticInfo &DI, void *Context) {
75   if (DI.getSeverity() != DS_Error) {
76     DiagnosticPrinterRawOStream DP(errs());
77     DI.print(DP);
78     errs() << '\n';
79     return;
80   }
81   sLastErrorString = "";
82   {
83     raw_string_ostream Stream(sLastErrorString);
84     DiagnosticPrinterRawOStream DP(Stream);
85     DI.print(DP);
86   }
87 }
88 
89 // Initialize the configured targets if they have not been initialized.
90 static void lto_initialize() {
91   if (!initialized) {
92 #ifdef LLVM_ON_WIN32
93     // Dialog box on crash disabling doesn't work across DLL boundaries, so do
94     // it here.
95     llvm::sys::DisableSystemDialogsOnCrash();
96 #endif
97 
98     InitializeAllTargetInfos();
99     InitializeAllTargets();
100     InitializeAllTargetMCs();
101     InitializeAllAsmParsers();
102     InitializeAllAsmPrinters();
103     InitializeAllDisassemblers();
104 
105     static LLVMContext Context;
106     LTOContext = &Context;
107     LTOContext->setDiagnosticHandler(diagnosticHandler, nullptr, true);
108     initialized = true;
109   }
110 }
111 
112 namespace {
113 
114 static void handleLibLTODiagnostic(lto_codegen_diagnostic_severity_t Severity,
115                                    const char *Msg, void *) {
116   sLastErrorString = Msg;
117 }
118 
119 // This derived class owns the native object file. This helps implement the
120 // libLTO API semantics, which require that the code generator owns the object
121 // file.
122 struct LibLTOCodeGenerator : LTOCodeGenerator {
123   LibLTOCodeGenerator() : LTOCodeGenerator(*LTOContext) { init(); }
124   LibLTOCodeGenerator(std::unique_ptr<LLVMContext> Context)
125       : LTOCodeGenerator(*Context), OwnedContext(std::move(Context)) {
126     init();
127   }
128 
129   // Reset the module first in case MergedModule is created in OwnedContext.
130   // Module must be destructed before its context gets destructed.
131   ~LibLTOCodeGenerator() { resetMergedModule(); }
132 
133   void init() { setDiagnosticHandler(handleLibLTODiagnostic, nullptr); }
134 
135   std::unique_ptr<MemoryBuffer> NativeObjectFile;
136   std::unique_ptr<LLVMContext> OwnedContext;
137 };
138 
139 }
140 
141 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LibLTOCodeGenerator, lto_code_gen_t)
142 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ThinLTOCodeGenerator, thinlto_code_gen_t)
143 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LTOModule, lto_module_t)
144 
145 // Convert the subtarget features into a string to pass to LTOCodeGenerator.
146 static void lto_add_attrs(lto_code_gen_t cg) {
147   LTOCodeGenerator *CG = unwrap(cg);
148   if (MAttrs.size()) {
149     std::string attrs;
150     for (unsigned i = 0; i < MAttrs.size(); ++i) {
151       if (i > 0)
152         attrs.append(",");
153       attrs.append(MAttrs[i]);
154     }
155 
156     CG->setAttr(attrs);
157   }
158 
159   if (OptLevel < '0' || OptLevel > '3')
160     report_fatal_error("Optimization level must be between 0 and 3");
161   CG->setOptLevel(OptLevel - '0');
162 }
163 
164 extern const char* lto_get_version() {
165   return LTOCodeGenerator::getVersionString();
166 }
167 
168 const char* lto_get_error_message() {
169   return sLastErrorString.c_str();
170 }
171 
172 bool lto_module_is_object_file(const char* path) {
173   return LTOModule::isBitcodeFile(StringRef(path));
174 }
175 
176 bool lto_module_is_object_file_for_target(const char* path,
177                                           const char* target_triplet_prefix) {
178   ErrorOr<std::unique_ptr<MemoryBuffer>> Buffer = MemoryBuffer::getFile(path);
179   if (!Buffer)
180     return false;
181   return LTOModule::isBitcodeForTarget(Buffer->get(),
182                                        StringRef(target_triplet_prefix));
183 }
184 
185 bool lto_module_has_objc_category(const void *mem, size_t length) {
186   std::unique_ptr<MemoryBuffer> Buffer(LTOModule::makeBuffer(mem, length));
187   if (!Buffer)
188     return false;
189   LLVMContext Ctx;
190   ErrorOr<bool> Result = expectedToErrorOrAndEmitErrors(
191       Ctx, llvm::isBitcodeContainingObjCCategory(*Buffer));
192   return Result && *Result;
193 }
194 
195 bool lto_module_is_object_file_in_memory(const void* mem, size_t length) {
196   return LTOModule::isBitcodeFile(mem, length);
197 }
198 
199 bool
200 lto_module_is_object_file_in_memory_for_target(const void* mem,
201                                             size_t length,
202                                             const char* target_triplet_prefix) {
203   std::unique_ptr<MemoryBuffer> buffer(LTOModule::makeBuffer(mem, length));
204   if (!buffer)
205     return false;
206   return LTOModule::isBitcodeForTarget(buffer.get(),
207                                        StringRef(target_triplet_prefix));
208 }
209 
210 lto_module_t lto_module_create(const char* path) {
211   lto_initialize();
212   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
213   ErrorOr<std::unique_ptr<LTOModule>> M =
214       LTOModule::createFromFile(*LTOContext, StringRef(path), Options);
215   if (!M)
216     return nullptr;
217   return wrap(M->release());
218 }
219 
220 lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) {
221   lto_initialize();
222   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
223   ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromOpenFile(
224       *LTOContext, fd, StringRef(path), size, Options);
225   if (!M)
226     return nullptr;
227   return wrap(M->release());
228 }
229 
230 lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path,
231                                                  size_t file_size,
232                                                  size_t map_size,
233                                                  off_t offset) {
234   lto_initialize();
235   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
236   ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromOpenFileSlice(
237       *LTOContext, fd, StringRef(path), map_size, offset, Options);
238   if (!M)
239     return nullptr;
240   return wrap(M->release());
241 }
242 
243 lto_module_t lto_module_create_from_memory(const void* mem, size_t length) {
244   lto_initialize();
245   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
246   ErrorOr<std::unique_ptr<LTOModule>> M =
247       LTOModule::createFromBuffer(*LTOContext, mem, length, Options);
248   if (!M)
249     return nullptr;
250   return wrap(M->release());
251 }
252 
253 lto_module_t lto_module_create_from_memory_with_path(const void* mem,
254                                                      size_t length,
255                                                      const char *path) {
256   lto_initialize();
257   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
258   ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromBuffer(
259       *LTOContext, mem, length, Options, StringRef(path));
260   if (!M)
261     return nullptr;
262   return wrap(M->release());
263 }
264 
265 lto_module_t lto_module_create_in_local_context(const void *mem, size_t length,
266                                                 const char *path) {
267   lto_initialize();
268   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
269 
270   // Create a local context. Ownership will be transfered to LTOModule.
271   std::unique_ptr<LLVMContext> Context = llvm::make_unique<LLVMContext>();
272   Context->setDiagnosticHandler(diagnosticHandler, nullptr, true);
273 
274   ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createInLocalContext(
275       std::move(Context), mem, length, Options, StringRef(path));
276   if (!M)
277     return nullptr;
278   return wrap(M->release());
279 }
280 
281 lto_module_t lto_module_create_in_codegen_context(const void *mem,
282                                                   size_t length,
283                                                   const char *path,
284                                                   lto_code_gen_t cg) {
285   lto_initialize();
286   llvm::TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
287   ErrorOr<std::unique_ptr<LTOModule>> M = LTOModule::createFromBuffer(
288       unwrap(cg)->getContext(), mem, length, Options, StringRef(path));
289   return wrap(M->release());
290 }
291 
292 void lto_module_dispose(lto_module_t mod) { delete unwrap(mod); }
293 
294 const char* lto_module_get_target_triple(lto_module_t mod) {
295   return unwrap(mod)->getTargetTriple().c_str();
296 }
297 
298 void lto_module_set_target_triple(lto_module_t mod, const char *triple) {
299   return unwrap(mod)->setTargetTriple(StringRef(triple));
300 }
301 
302 unsigned int lto_module_get_num_symbols(lto_module_t mod) {
303   return unwrap(mod)->getSymbolCount();
304 }
305 
306 const char* lto_module_get_symbol_name(lto_module_t mod, unsigned int index) {
307   return unwrap(mod)->getSymbolName(index).data();
308 }
309 
310 lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod,
311                                                       unsigned int index) {
312   return unwrap(mod)->getSymbolAttributes(index);
313 }
314 
315 const char* lto_module_get_linkeropts(lto_module_t mod) {
316   return unwrap(mod)->getLinkerOpts().data();
317 }
318 
319 void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg,
320                                         lto_diagnostic_handler_t diag_handler,
321                                         void *ctxt) {
322   unwrap(cg)->setDiagnosticHandler(diag_handler, ctxt);
323 }
324 
325 static lto_code_gen_t createCodeGen(bool InLocalContext) {
326   lto_initialize();
327 
328   TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
329 
330   LibLTOCodeGenerator *CodeGen =
331       InLocalContext ? new LibLTOCodeGenerator(make_unique<LLVMContext>())
332                      : new LibLTOCodeGenerator();
333   CodeGen->setTargetOptions(Options);
334   return wrap(CodeGen);
335 }
336 
337 lto_code_gen_t lto_codegen_create(void) {
338   return createCodeGen(/* InLocalContext */ false);
339 }
340 
341 lto_code_gen_t lto_codegen_create_in_local_context(void) {
342   return createCodeGen(/* InLocalContext */ true);
343 }
344 
345 void lto_codegen_dispose(lto_code_gen_t cg) { delete unwrap(cg); }
346 
347 bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) {
348   return !unwrap(cg)->addModule(unwrap(mod));
349 }
350 
351 void lto_codegen_set_module(lto_code_gen_t cg, lto_module_t mod) {
352   unwrap(cg)->setModule(std::unique_ptr<LTOModule>(unwrap(mod)));
353 }
354 
355 bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) {
356   unwrap(cg)->setDebugInfo(debug);
357   return false;
358 }
359 
360 bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
361   switch (model) {
362   case LTO_CODEGEN_PIC_MODEL_STATIC:
363     unwrap(cg)->setCodePICModel(Reloc::Static);
364     return false;
365   case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
366     unwrap(cg)->setCodePICModel(Reloc::PIC_);
367     return false;
368   case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
369     unwrap(cg)->setCodePICModel(Reloc::DynamicNoPIC);
370     return false;
371   case LTO_CODEGEN_PIC_MODEL_DEFAULT:
372     unwrap(cg)->setCodePICModel(None);
373     return false;
374   }
375   sLastErrorString = "Unknown PIC model";
376   return true;
377 }
378 
379 void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) {
380   return unwrap(cg)->setCpu(cpu);
381 }
382 
383 void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char *path) {
384   // In here only for backwards compatibility. We use MC now.
385 }
386 
387 void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args,
388                                     int nargs) {
389   // In here only for backwards compatibility. We use MC now.
390 }
391 
392 void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg,
393                                           const char *symbol) {
394   unwrap(cg)->addMustPreserveSymbol(symbol);
395 }
396 
397 static void maybeParseOptions(lto_code_gen_t cg) {
398   if (!parsedOptions) {
399     unwrap(cg)->parseCodeGenDebugOptions();
400     lto_add_attrs(cg);
401     parsedOptions = true;
402   }
403 }
404 
405 bool lto_codegen_write_merged_modules(lto_code_gen_t cg, const char *path) {
406   maybeParseOptions(cg);
407   return !unwrap(cg)->writeMergedModules(path);
408 }
409 
410 const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) {
411   maybeParseOptions(cg);
412   LibLTOCodeGenerator *CG = unwrap(cg);
413   CG->NativeObjectFile =
414       CG->compile(DisableVerify, DisableInline, DisableGVNLoadPRE,
415                   DisableLTOVectorization);
416   if (!CG->NativeObjectFile)
417     return nullptr;
418   *length = CG->NativeObjectFile->getBufferSize();
419   return CG->NativeObjectFile->getBufferStart();
420 }
421 
422 bool lto_codegen_optimize(lto_code_gen_t cg) {
423   maybeParseOptions(cg);
424   return !unwrap(cg)->optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
425                                DisableLTOVectorization);
426 }
427 
428 const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) {
429   maybeParseOptions(cg);
430   LibLTOCodeGenerator *CG = unwrap(cg);
431   CG->NativeObjectFile = CG->compileOptimized();
432   if (!CG->NativeObjectFile)
433     return nullptr;
434   *length = CG->NativeObjectFile->getBufferSize();
435   return CG->NativeObjectFile->getBufferStart();
436 }
437 
438 bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) {
439   maybeParseOptions(cg);
440   return !unwrap(cg)->compile_to_file(
441       name, DisableVerify, DisableInline, DisableGVNLoadPRE,
442       DisableLTOVectorization);
443 }
444 
445 void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {
446   unwrap(cg)->setCodeGenDebugOptions(opt);
447 }
448 
449 unsigned int lto_api_version() { return LTO_API_VERSION; }
450 
451 void lto_codegen_set_should_internalize(lto_code_gen_t cg,
452                                         bool ShouldInternalize) {
453   unwrap(cg)->setShouldInternalize(ShouldInternalize);
454 }
455 
456 void lto_codegen_set_should_embed_uselists(lto_code_gen_t cg,
457                                            lto_bool_t ShouldEmbedUselists) {
458   unwrap(cg)->setShouldEmbedUselists(ShouldEmbedUselists);
459 }
460 
461 // ThinLTO API below
462 
463 thinlto_code_gen_t thinlto_create_codegen(void) {
464   lto_initialize();
465   ThinLTOCodeGenerator *CodeGen = new ThinLTOCodeGenerator();
466   CodeGen->setTargetOptions(InitTargetOptionsFromCodeGenFlags());
467 
468   if (OptLevel.getNumOccurrences()) {
469     if (OptLevel < '0' || OptLevel > '3')
470       report_fatal_error("Optimization level must be between 0 and 3");
471     CodeGen->setOptLevel(OptLevel - '0');
472     switch (OptLevel) {
473     case '0':
474       CodeGen->setCodeGenOptLevel(CodeGenOpt::None);
475       break;
476     case '1':
477       CodeGen->setCodeGenOptLevel(CodeGenOpt::Less);
478       break;
479     case '2':
480       CodeGen->setCodeGenOptLevel(CodeGenOpt::Default);
481       break;
482     case '3':
483       CodeGen->setCodeGenOptLevel(CodeGenOpt::Aggressive);
484       break;
485     }
486   }
487   return wrap(CodeGen);
488 }
489 
490 void thinlto_codegen_dispose(thinlto_code_gen_t cg) { delete unwrap(cg); }
491 
492 void thinlto_codegen_add_module(thinlto_code_gen_t cg, const char *Identifier,
493                                 const char *Data, int Length) {
494   unwrap(cg)->addModule(Identifier, StringRef(Data, Length));
495 }
496 
497 void thinlto_codegen_process(thinlto_code_gen_t cg) { unwrap(cg)->run(); }
498 
499 unsigned int thinlto_module_get_num_objects(thinlto_code_gen_t cg) {
500   return unwrap(cg)->getProducedBinaries().size();
501 }
502 LTOObjectBuffer thinlto_module_get_object(thinlto_code_gen_t cg,
503                                           unsigned int index) {
504   assert(index < unwrap(cg)->getProducedBinaries().size() && "Index overflow");
505   auto &MemBuffer = unwrap(cg)->getProducedBinaries()[index];
506   return LTOObjectBuffer{MemBuffer->getBufferStart(),
507                          MemBuffer->getBufferSize()};
508 }
509 
510 unsigned int thinlto_module_get_num_object_files(thinlto_code_gen_t cg) {
511   return unwrap(cg)->getProducedBinaryFiles().size();
512 }
513 const char *thinlto_module_get_object_file(thinlto_code_gen_t cg,
514                                            unsigned int index) {
515   assert(index < unwrap(cg)->getProducedBinaryFiles().size() &&
516          "Index overflow");
517   return unwrap(cg)->getProducedBinaryFiles()[index].c_str();
518 }
519 
520 void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg,
521                                      lto_bool_t disable) {
522   unwrap(cg)->disableCodeGen(disable);
523 }
524 
525 void thinlto_codegen_set_codegen_only(thinlto_code_gen_t cg,
526                                       lto_bool_t CodeGenOnly) {
527   unwrap(cg)->setCodeGenOnly(CodeGenOnly);
528 }
529 
530 void thinlto_debug_options(const char *const *options, int number) {
531   // if options were requested, set them
532   if (number && options) {
533     std::vector<const char *> CodegenArgv(1, "libLTO");
534     for (auto Arg : ArrayRef<const char *>(options, number))
535       CodegenArgv.push_back(Arg);
536     cl::ParseCommandLineOptions(CodegenArgv.size(), CodegenArgv.data());
537   }
538 }
539 
540 lto_bool_t lto_module_is_thinlto(lto_module_t mod) {
541   return unwrap(mod)->isThinLTO();
542 }
543 
544 void thinlto_codegen_add_must_preserve_symbol(thinlto_code_gen_t cg,
545                                               const char *Name, int Length) {
546   unwrap(cg)->preserveSymbol(StringRef(Name, Length));
547 }
548 
549 void thinlto_codegen_add_cross_referenced_symbol(thinlto_code_gen_t cg,
550                                                  const char *Name, int Length) {
551   unwrap(cg)->crossReferenceSymbol(StringRef(Name, Length));
552 }
553 
554 void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const char *cpu) {
555   return unwrap(cg)->setCpu(cpu);
556 }
557 
558 void thinlto_codegen_set_cache_dir(thinlto_code_gen_t cg,
559                                    const char *cache_dir) {
560   return unwrap(cg)->setCacheDir(cache_dir);
561 }
562 
563 void thinlto_codegen_set_cache_pruning_interval(thinlto_code_gen_t cg,
564                                                 int interval) {
565   return unwrap(cg)->setCachePruningInterval(interval);
566 }
567 
568 void thinlto_codegen_set_cache_entry_expiration(thinlto_code_gen_t cg,
569                                                 unsigned expiration) {
570   return unwrap(cg)->setCacheEntryExpiration(expiration);
571 }
572 
573 void thinlto_codegen_set_final_cache_size_relative_to_available_space(
574     thinlto_code_gen_t cg, unsigned Percentage) {
575   return unwrap(cg)->setMaxCacheSizeRelativeToAvailableSpace(Percentage);
576 }
577 
578 void thinlto_codegen_set_savetemps_dir(thinlto_code_gen_t cg,
579                                        const char *save_temps_dir) {
580   return unwrap(cg)->setSaveTempsDir(save_temps_dir);
581 }
582 
583 void thinlto_set_generated_objects_dir(thinlto_code_gen_t cg,
584                                        const char *save_temps_dir) {
585   unwrap(cg)->setGeneratedObjectsDirectory(save_temps_dir);
586 }
587 
588 lto_bool_t thinlto_codegen_set_pic_model(thinlto_code_gen_t cg,
589                                          lto_codegen_model model) {
590   switch (model) {
591   case LTO_CODEGEN_PIC_MODEL_STATIC:
592     unwrap(cg)->setCodePICModel(Reloc::Static);
593     return false;
594   case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
595     unwrap(cg)->setCodePICModel(Reloc::PIC_);
596     return false;
597   case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
598     unwrap(cg)->setCodePICModel(Reloc::DynamicNoPIC);
599     return false;
600   case LTO_CODEGEN_PIC_MODEL_DEFAULT:
601     unwrap(cg)->setCodePICModel(None);
602     return false;
603   }
604   sLastErrorString = "Unknown PIC model";
605   return true;
606 }
607