#include "llvm/Transforms/IPO/ConstantMerge.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/IPO.h"
#include <algorithm>
#include <cassert>
#include <utility>
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumIdenticalMerged, "Number of identical global constants merged");
static void FindUsedValues(GlobalVariable *LLVMUsed,
SmallPtrSetImpl<const GlobalValue*> &UsedValues) { … }
static bool IsBetterCanonical(const GlobalVariable &A,
const GlobalVariable &B) { … }
static bool hasMetadataOtherThanDebugLoc(const GlobalVariable *GV) { … }
static void copyDebugLocMetadata(const GlobalVariable *From,
GlobalVariable *To) { … }
static Align getAlign(GlobalVariable *GV) { … }
static bool
isUnmergeableGlobal(GlobalVariable *GV,
const SmallPtrSetImpl<const GlobalValue *> &UsedGlobals) { … }
enum class CanMerge { … };
static CanMerge makeMergeable(GlobalVariable *Old, GlobalVariable *New) { … }
static void replace(Module &M, GlobalVariable *Old, GlobalVariable *New) { … }
static bool mergeConstants(Module &M) { … }
PreservedAnalyses ConstantMergePass::run(Module &M, ModuleAnalysisManager &) { … }