LLVM 19.0.0git
Macros | Enumerations | Functions
ConstantMerge.cpp File Reference
#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/Transforms/IPO.h"
#include <algorithm>
#include <cassert>
#include <utility>

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "constmerge"
 

Enumerations

enum class  CanMerge { No , Yes }
 

Functions

 STATISTIC (NumIdenticalMerged, "Number of identical global constants merged")
 
static void FindUsedValues (GlobalVariable *LLVMUsed, SmallPtrSetImpl< const GlobalValue * > &UsedValues)
 Find values that are marked as llvm.used.
 
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)
 
static CanMerge makeMergeable (GlobalVariable *Old, GlobalVariable *New)
 
static void replace (Module &M, GlobalVariable *Old, GlobalVariable *New)
 
static bool mergeConstants (Module &M)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "constmerge"

Definition at line 39 of file ConstantMerge.cpp.

Enumeration Type Documentation

◆ CanMerge

enum class CanMerge
strong
Enumerator
No 
Yes 

Definition at line 102 of file ConstantMerge.cpp.

Function Documentation

◆ copyDebugLocMetadata()

static void copyDebugLocMetadata ( const GlobalVariable From,
GlobalVariable To 
)
static

Definition at line 77 of file ConstantMerge.cpp.

References llvm::GlobalVariable::addDebugInfo(), and From.

Referenced by replace().

◆ FindUsedValues()

static void FindUsedValues ( GlobalVariable LLVMUsed,
SmallPtrSetImpl< const GlobalValue * > &  UsedValues 
)
static

◆ getAlign()

static Align getAlign ( GlobalVariable GV)
static

◆ hasMetadataOtherThanDebugLoc()

static bool hasMetadataOtherThanDebugLoc ( const GlobalVariable GV)
static

Definition at line 68 of file ConstantMerge.cpp.

References llvm::GlobalObject::getAllMetadata().

Referenced by makeMergeable(), and mergeConstants().

◆ IsBetterCanonical()

static bool IsBetterCanonical ( const GlobalVariable A,
const GlobalVariable B 
)
static

Definition at line 57 of file ConstantMerge.cpp.

References A, and B.

Referenced by mergeConstants().

◆ isUnmergeableGlobal()

static bool isUnmergeableGlobal ( GlobalVariable GV,
const SmallPtrSetImpl< const GlobalValue * > &  UsedGlobals 
)
static

◆ makeMergeable()

static CanMerge makeMergeable ( GlobalVariable Old,
GlobalVariable New 
)
static

◆ mergeConstants()

static bool mergeConstants ( Module M)
static

◆ replace()

static void replace ( Module M,
GlobalVariable Old,
GlobalVariable New 
)
static

◆ STATISTIC()

STATISTIC ( NumIdenticalMerged  ,
"Number of identical global constants merged"   
)