55 if (!isa<Constant>(U))
58 auto *
GEP = dyn_cast<GEPOperator>(U);
59 if (!
GEP || !
GEP->getInRangeIndex() || *
GEP->getInRangeIndex() != 1 ||
60 !isa<ConstantInt>(
GEP->getOperand(1)) ||
61 !cast<ConstantInt>(
GEP->getOperand(1))->isZero() ||
62 !isa<ConstantInt>(
GEP->getOperand(2)))
74 std::vector<GlobalVariable *> SplitGlobals(
Init->getNumOperands());
75 for (
unsigned I = 0;
I !=
Init->getNumOperands(); ++
I) {
81 SplitGlobals[
I] = SplitGV;
84 unsigned SplitEnd = (
I ==
Init->getNumOperands() - 1)
91 uint64_t ByteOffset = cast<ConstantInt>(
92 cast<ConstantAsMetadata>(
Type->getOperand(0))->getValue())
102 uint64_t AttachedTo = (ByteOffset == 0) ? ByteOffset : ByteOffset - 1;
103 if (AttachedTo < SplitBegin || AttachedTo >= SplitEnd)
105 SplitGV->addMetadata(
106 LLVMContext::MD_type,
108 {ConstantAsMetadata::get(
109 ConstantInt::get(Int32Ty, ByteOffset - SplitBegin)),
110 Type->getOperand(1)}));
113 if (GV.
hasMetadata(LLVMContext::MD_vcall_visibility))
118 auto *
GEP = cast<GEPOperator>(U);
119 unsigned I = cast<ConstantInt>(
GEP->getOperand(2))->getZExtValue();
120 if (
I >= SplitGlobals.size())
125 for (
unsigned I = 3;
I !=
GEP->getNumOperands(); ++
I)
129 SplitGlobals[
I]->getInitializer()->
getType(), SplitGlobals[
I], Ops,
131 GEP->replaceAllUsesWith(NewGEP);
150 Function *TypeCheckedLoadRelativeFunc =
152 if ((!TypeTestFunc || TypeTestFunc->
use_empty()) &&
153 (!TypeCheckedLoadFunc || TypeCheckedLoadFunc->
use_empty()) &&
154 (!TypeCheckedLoadRelativeFunc ||
155 TypeCheckedLoadRelativeFunc->
use_empty()))
158 bool Changed =
false;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool splitGlobals(Module &M)
static bool splitGlobal(GlobalVariable &GV)
Module.h This file contains the declarations for the Module class.
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
A container for analyses that lazily runs them and caches their results.
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, std::optional< unsigned > InRangeIndex=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
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.
A parsed version of the target data layout string in and methods for querying it.
bool hasMetadata() const
Return true if this value has any metadata attached to it.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
VCallVisibility getVCallVisibility() const
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
bool hasLocalLinkage() const
Module * getParent()
Get the module that this global value is contained inside of...
PointerType * getType() const
Global values are always pointers.
@ PrivateLinkage
Like Internal, but omit from symbol table.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Class to represent integer types.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
A Module instance is used to store all the information related to an LLVM module.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
TypeSize getSizeInBytes() const
TypeSize getElementOffset(unsigned Idx) const
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt32Ty(LLVMContext &C)
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
LLVMContext & getContext() const
All values hold a context through their type.
StringRef getName() const
Return a constant reference to the value's name.
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
This is an optimization pass for GlobalISel generic memory operations.
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...