LLVM
15.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/InitializePasses.h"
#include "llvm/Pass.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 | CanMerge { CanMerge::No, CanMerge::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. More... | |
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) |
INITIALIZE_PASS (ConstantMergeLegacyPass, "constmerge", "Merge Duplicate Global Constants", false, false) ModulePass *llvm | |
#define DEBUG_TYPE "constmerge" |
Definition at line 41 of file ConstantMerge.cpp.
|
strong |
Enumerator | |
---|---|
No | |
Yes |
Definition at line 104 of file ConstantMerge.cpp.
|
static |
Definition at line 79 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 46 of file ConstantMerge.cpp.
References llvm::numbers::e, llvm::GlobalVariable::getInitializer(), llvm::User::getNumOperands(), llvm::User::getOperand(), i, llvm::SmallPtrSetImpl< PtrType >::insert(), and llvm::Value::stripPointerCasts().
Referenced by mergeConstants().
|
static |
Definition at line 87 of file ConstantMerge.cpp.
References llvm::GlobalObject::getAlign(), llvm::Module::getDataLayout(), llvm::GlobalValue::getParent(), llvm::DataLayout::getPreferredAlign(), and llvm::Optional< T >::value_or().
|
static |
Definition at line 70 of file ConstantMerge.cpp.
References llvm::GlobalObject::getAllMetadata().
Referenced by makeMergeable(), and mergeConstants().
INITIALIZE_PASS | ( | ConstantMergeLegacyPass | , |
"constmerge" | , | ||
"Merge Duplicate Global Constants" | , | ||
false | , | ||
false | |||
) |
Definition at line 277 of file ConstantMerge.cpp.
|
static |
|
static |
Definition at line 93 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 105 of file ConstantMerge.cpp.
References assert(), llvm::GlobalValue::hasGlobalUnnamedAddr(), hasMetadataOtherThanDebugLoc(), No, llvm::GlobalValue::None, and Yes.
Referenced by mergeConstants().
|
static |
Definition at line 135 of file ConstantMerge.cpp.
References llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::clear(), llvm::SmallVectorImpl< T >::clear(), llvm::dbgs(), llvm::numbers::e, llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::end(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::find(), FindUsedValues(), hasMetadataOtherThanDebugLoc(), i, IsBetterCanonical(), isUnmergeableGlobal(), LLVM_DEBUG, M, llvm::make_early_inc_range(), makeMergeable(), No, and llvm::replace().
Referenced by llvm::ConstantMergePass::run().
|
static |
Definition at line 116 of file ConstantMerge.cpp.
References assert(), copyDebugLocMetadata(), llvm::dbgs(), llvm::GlobalVariable::eraseFromParent(), llvm::GlobalObject::getAlign(), llvm::getAlign(), llvm::Value::getName(), llvm::GlobalValue::hasLocalLinkage(), LLVM_DEBUG, llvm::max(), and llvm::Value::replaceAllUsesWith().
Referenced by llvm::sys::path::convert_to_slash(), llvm::BaseRecord::getFormattedName(), getSignature(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), lowerV8I16GeneralSingleInputShuffle(), llvm::sys::path::native(), replaceIllegalFilenameChars(), llvm::LiveVariables::replaceKillInstruction(), and llvm::UnrollLoop().
STATISTIC | ( | NumIdenticalMerged | , |
"Number of identical global constants merged" | |||
) |