LLVM 20.0.0git
GlobalMerge.h
Go to the documentation of this file.
1//===- llvm/CodeGen/GlobalMerge.h -------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CODEGEN_GLOBALMERGE_H
10#define LLVM_CODEGEN_GLOBALMERGE_H
11
12#include "llvm/IR/PassManager.h"
13
14namespace llvm {
15
16class TargetMachine;
17
19 // FIXME: Infer the maximum possible offset depending on the actual users
20 // (these max offsets are different for the users inside Thumb or ARM
21 // functions), see the code that passes in the offset in the ARM backend
22 // for more information.
23 unsigned MaxOffset = 0;
24 // The minimum size in bytes of each global that should considered in merging.
25 unsigned MinSize = 0;
26 bool GroupByUse = true;
27 bool IgnoreSingleUse = true;
28 bool MergeConst = false;
29 /// Whether we should merge global variables that have external linkage.
30 bool MergeExternal = true;
31 /// Whether we should merge constant global variables.
33 /// Whether we should try to optimize for size only.
34 /// Currently, this applies a dead simple heuristic: only consider globals
35 /// used in minsize functions for merging.
36 /// FIXME: This could learn about optsize, and be used in the cost model.
37 bool SizeOnly = false;
38};
39
40// FIXME: This pass must run before AsmPrinterPass::doInitialization!
41class GlobalMergePass : public PassInfoMixin<GlobalMergePass> {
42 const TargetMachine *TM;
43 GlobalMergeOptions Options;
44
45public:
47 : TM(TM), Options(Options) {}
48
50};
51
52} // namespace llvm
53
54#endif // LLVM_CODEGEN_GLOBALMERGE_H
ModuleAnalysisManager MAM
This header defines various interfaces for pass management in LLVM.
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
GlobalMergePass(const TargetMachine *TM, GlobalMergeOptions Options)
Definition: GlobalMerge.h:46
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool SizeOnly
Whether we should try to optimize for size only.
Definition: GlobalMerge.h:37
bool MergeExternal
Whether we should merge global variables that have external linkage.
Definition: GlobalMerge.h:30
bool MergeConstantGlobals
Whether we should merge constant global variables.
Definition: GlobalMerge.h:32
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:69