File indexing completed on 2026-05-10 08:44:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef LLVM_TRANSFORMS_IPO_GLOBALDCE_H
0018 #define LLVM_TRANSFORMS_IPO_GLOBALDCE_H
0019
0020 #include "llvm/ADT/DenseMap.h"
0021 #include "llvm/ADT/SmallSet.h"
0022 #include "llvm/IR/GlobalValue.h"
0023 #include "llvm/IR/PassManager.h"
0024 #include <unordered_map>
0025
0026 namespace llvm {
0027 class Comdat;
0028 class Constant;
0029 class Function;
0030 class GlobalVariable;
0031 class Metadata;
0032 class Module;
0033 class Value;
0034
0035
0036 class GlobalDCEPass : public PassInfoMixin<GlobalDCEPass> {
0037 public:
0038 GlobalDCEPass(bool InLTOPostLink = false) : InLTOPostLink(InLTOPostLink) {}
0039
0040 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
0041
0042 void printPipeline(raw_ostream &OS,
0043 function_ref<StringRef(StringRef)> MapClassName2PassName);
0044
0045 private:
0046 bool InLTOPostLink = false;
0047
0048 SmallPtrSet<GlobalValue*, 32> AliveGlobals;
0049
0050
0051 DenseMap<GlobalValue *, SmallPtrSet<GlobalValue *, 4>> GVDependencies;
0052
0053
0054 std::unordered_map<Constant *, SmallPtrSet<GlobalValue *, 8>>
0055 ConstantDependenciesCache;
0056
0057
0058 std::unordered_multimap<Comdat *, GlobalValue *> ComdatMembers;
0059
0060
0061 DenseMap<Metadata *, SmallSet<std::pair<GlobalVariable *, uint64_t>, 4>>
0062 TypeIdMap;
0063
0064
0065
0066 SmallPtrSet<GlobalValue *, 32> VFESafeVTables;
0067
0068 void UpdateGVDependencies(GlobalValue &GV);
0069 void MarkLive(GlobalValue &GV,
0070 SmallVectorImpl<GlobalValue *> *Updates = nullptr);
0071
0072
0073 void AddVirtualFunctionDependencies(Module &M);
0074 void ScanVTables(Module &M);
0075 void ScanTypeCheckedLoadIntrinsics(Module &M);
0076 void ScanVTableLoad(Function *Caller, Metadata *TypeId, uint64_t CallOffset);
0077
0078 void ComputeDependencies(Value *V, SmallPtrSetImpl<GlobalValue *> &U);
0079 };
0080
0081 }
0082
0083 #endif