LLVM 20.0.0git
|
#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>
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) |
#define DEBUG_TYPE "constmerge" |
Definition at line 40 of file ConstantMerge.cpp.
|
strong |
Enumerator | |
---|---|
No | |
Yes |
Definition at line 103 of file ConstantMerge.cpp.
|
static |
Definition at line 78 of file ConstantMerge.cpp.
References llvm::GlobalVariable::addDebugInfo(), and From.
Referenced by replace().
|
static |
Find values that are marked as llvm.used.
Definition at line 45 of file ConstantMerge.cpp.
References llvm::GlobalVariable::getInitializer(), llvm::User::getNumOperands(), llvm::User::getOperand(), llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::Value::stripPointerCasts().
Referenced by mergeConstants().
|
static |
Definition at line 86 of file ConstantMerge.cpp.
References llvm::GlobalObject::getAlign(), llvm::GlobalValue::getDataLayout(), and llvm::DataLayout::getPreferredAlign().
Referenced by replace().
|
static |
Definition at line 69 of file ConstantMerge.cpp.
References llvm::GlobalObject::getAllMetadata().
Referenced by makeMergeable(), and mergeConstants().
|
static |
Definition at line 58 of file ConstantMerge.cpp.
Referenced by mergeConstants().
|
static |
Definition at line 92 of file ConstantMerge.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::PointerType::getAddressSpace(), llvm::GlobalValue::getType(), llvm::GlobalVariable::hasDefinitiveInitializer(), llvm::GlobalObject::hasSection(), llvm::GlobalVariable::isConstant(), and llvm::GlobalValue::isThreadLocal().
Referenced by mergeConstants().
|
static |
Definition at line 104 of file ConstantMerge.cpp.
References assert(), llvm::GlobalValue::hasGlobalUnnamedAddr(), hasMetadataOtherThanDebugLoc(), No, and Yes.
Referenced by mergeConstants().
Definition at line 134 of file ConstantMerge.cpp.
References llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::dbgs(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), FindUsedValues(), hasMetadataOtherThanDebugLoc(), IsBetterCanonical(), isUnmergeableGlobal(), LLVM_DEBUG, llvm::make_early_inc_range(), makeMergeable(), No, llvm::SmallVectorTemplateBase< T, bool >::push_back(), replace(), and llvm::SmallVectorBase< Size_T >::size().
Referenced by llvm::ConstantMergePass::run().
|
static |
Definition at line 115 of file ConstantMerge.cpp.
References assert(), copyDebugLocMetadata(), llvm::dbgs(), llvm::GlobalVariable::eraseFromParent(), llvm::GlobalObject::getAlign(), getAlign(), llvm::Value::getName(), llvm::GlobalValue::hasLocalLinkage(), LLVM_DEBUG, and llvm::Value::replaceAllUsesWith().
Referenced by mergeConstants().
STATISTIC | ( | NumIdenticalMerged | , |
"Number of identical global constants merged" | |||
) |