Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:28

0001 //===- llvm/CodeGen/GlobalMerge.h -------------------------------*- 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 
0009 #ifndef LLVM_CODEGEN_GLOBALMERGE_H
0010 #define LLVM_CODEGEN_GLOBALMERGE_H
0011 
0012 #include "llvm/IR/PassManager.h"
0013 
0014 namespace llvm {
0015 
0016 class TargetMachine;
0017 
0018 struct GlobalMergeOptions {
0019   // FIXME: Infer the maximum possible offset depending on the actual users
0020   // (these max offsets are different for the users inside Thumb or ARM
0021   // functions), see the code that passes in the offset in the ARM backend
0022   // for more information.
0023   unsigned MaxOffset = 0;
0024   // The minimum size in bytes of each global that should considered in merging.
0025   unsigned MinSize = 0;
0026   bool GroupByUse = true;
0027   bool IgnoreSingleUse = true;
0028   bool MergeConst = false;
0029   /// Whether we should merge global variables that have external linkage.
0030   bool MergeExternal = true;
0031   /// Whether we should merge constant global variables.
0032   bool MergeConstantGlobals = false;
0033   /// Whether we should merge constant global variables aggressively without
0034   /// looking at use.
0035   bool MergeConstAggressive = false;
0036   /// Whether we should try to optimize for size only.
0037   /// Currently, this applies a dead simple heuristic: only consider globals
0038   /// used in minsize functions for merging.
0039   /// FIXME: This could learn about optsize, and be used in the cost model.
0040   bool SizeOnly = false;
0041 };
0042 
0043 // FIXME: This pass must run before AsmPrinterPass::doInitialization!
0044 class GlobalMergePass : public PassInfoMixin<GlobalMergePass> {
0045   const TargetMachine *TM;
0046   GlobalMergeOptions Options;
0047 
0048 public:
0049   GlobalMergePass(const TargetMachine *TM, GlobalMergeOptions Options)
0050       : TM(TM), Options(Options) {}
0051 
0052   PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
0053 };
0054 
0055 } // namespace llvm
0056 
0057 #endif // LLVM_CODEGEN_GLOBALMERGE_H