Go to the documentation of this file.
57 if (!isa<Constant>(U))
60 auto *
GEP = dyn_cast<GEPOperator>(U);
61 if (!
GEP || !
GEP->getInRangeIndex() || *
GEP->getInRangeIndex() != 1 ||
62 !isa<ConstantInt>(
GEP->getOperand(1)) ||
63 !cast<ConstantInt>(
GEP->getOperand(1))->isZero() ||
64 !isa<ConstantInt>(
GEP->getOperand(2)))
76 std::vector<GlobalVariable *> SplitGlobals(
Init->getNumOperands());
77 for (
unsigned I = 0;
I !=
Init->getNumOperands(); ++
I) {
83 SplitGlobals[
I] = SplitGV;
86 unsigned SplitEnd = (
I ==
Init->getNumOperands() - 1)
93 uint64_t ByteOffset = cast<ConstantInt>(
94 cast<ConstantAsMetadata>(
Type->getOperand(0))->getValue())
104 uint64_t AttachedTo = (ByteOffset == 0) ? ByteOffset : ByteOffset - 1;
105 if (AttachedTo < SplitBegin || AttachedTo >= SplitEnd)
107 SplitGV->addMetadata(
108 LLVMContext::MD_type,
110 {ConstantAsMetadata::get(
111 ConstantInt::get(Int32Ty, ByteOffset - SplitBegin)),
112 Type->getOperand(1)}));
115 if (GV.
hasMetadata(LLVMContext::MD_vcall_visibility))
120 auto *
GEP = cast<GEPOperator>(U);
121 unsigned I = cast<ConstantInt>(
GEP->getOperand(2))->getZExtValue();
122 if (
I >= SplitGlobals.size())
127 for (
unsigned I = 3;
I !=
GEP->getNumOperands(); ++
I)
128 Ops.push_back(
GEP->getOperand(
I));
131 SplitGlobals[
I]->getInitializer()->
getType(), SplitGlobals[
I], Ops,
133 GEP->replaceAllUsesWith(NewGEP);
152 if ((!TypeTestFunc || TypeTestFunc->
use_empty()) &&
153 (!TypeCheckedLoadFunc || TypeCheckedLoadFunc->
use_empty()))
156 bool Changed =
false;
171 bool runOnModule(
Module &M)
override {
183 INITIALIZE_PASS(GlobalSplit,
"globalsplit",
"Global splitter",
false,
false)
186 return new GlobalSplit;
A set of analyses that are preserved following a run of a transformation pass.
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
A parsed version of the target data layout string in and methods for querying it.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt32Ty(LLVMContext &C)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
ModulePass * createGlobalSplitPass()
This pass splits globals into pieces for the benefit of whole-program devirtualization and control-fl...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Class to represent integer types.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static bool splitGlobals(Module &M)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
Module * getParent()
Get the module that this global value is contained inside of...
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool hasLocalLinkage() const
A Module instance is used to store all the information related to an LLVM module.
uint64_t getSizeInBytes() const
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
bool hasMetadata() const
Return true if this value has any metadata attached to it.
StringRef getName() const
Return a constant reference to the value's name.
void initializeGlobalSplitPass(PassRegistry &)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
uint64_t getElementOffset(unsigned Idx) const
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
@ PrivateLinkage
Like Internal, but omit from symbol table.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
VCallVisibility getVCallVisibility() const
PointerType * getType() const
Global values are always pointers.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
A container for analyses that lazily runs them and caches their results.
iterator_range< user_iterator > users()
static bool splitGlobal(GlobalVariable &GV)
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.