Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:40

0001 //===-- EmbedBitcodePass.h - Embeds bitcode into global ---------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 /// \file
0009 ///
0010 /// This file provides a pass which clones the current module and runs the
0011 /// provided pass pipeline on the clone. The optimized module is stored into a
0012 /// global variable in the `.llvm.lto` section. Primarily, this pass is used
0013 /// to support the FatLTO pipeline, but could be used to generate a bitcode
0014 /// section for any arbitrary pass pipeline without changing the current module.
0015 ///
0016 //===----------------------------------------------------------------------===//
0017 //
0018 #ifndef LLVM_TRANSFORMS_IPO_EMBEDBITCODEPASS_H
0019 #define LLVM_TRANSFORMS_IPO_EMBEDBITCODEPASS_H
0020 
0021 #include "llvm/IR/PassManager.h"
0022 
0023 namespace llvm {
0024 class Module;
0025 class Pass;
0026 
0027 struct EmbedBitcodeOptions {
0028   EmbedBitcodeOptions() : EmbedBitcodeOptions(false, false) {}
0029   EmbedBitcodeOptions(bool IsThinLTO, bool EmitLTOSummary)
0030       : IsThinLTO(IsThinLTO), EmitLTOSummary(EmitLTOSummary) {}
0031   bool IsThinLTO;
0032   bool EmitLTOSummary;
0033 };
0034 
0035 /// Pass embeds a copy of the module optimized with the provided pass pipeline
0036 /// into a global variable.
0037 class EmbedBitcodePass : public PassInfoMixin<EmbedBitcodePass> {
0038   bool IsThinLTO;
0039   bool EmitLTOSummary;
0040 
0041 public:
0042   EmbedBitcodePass(EmbedBitcodeOptions Opts)
0043       : EmbedBitcodePass(Opts.IsThinLTO, Opts.EmitLTOSummary) {}
0044   EmbedBitcodePass(bool IsThinLTO, bool EmitLTOSummary)
0045       : IsThinLTO(IsThinLTO), EmitLTOSummary(EmitLTOSummary) {}
0046 
0047   PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
0048 
0049   static bool isRequired() { return true; }
0050 };
0051 
0052 } // end namespace llvm.
0053 
0054 #endif