52 unsigned IndexWidth =
DL.getIndexTypeSizeInBits(GV.
getType());
59 APInt MemberRelativeOffset;
62 :
GEP(
GEP), MemberIndex(MemberIndex),
63 MemberRelativeOffset(std::move(MemberRelativeOffset)) {}
67 auto *
GEP = dyn_cast<GEPOperator>(U);
71 std::optional<ConstantRange>
InRange =
GEP->getInRange();
91 unsigned MemberIndex =
93 TypeSize MemberStart = MemberOffsets[MemberIndex];
94 TypeSize MemberEnd = MemberIndex == MemberOffsets.
size() - 1
96 : MemberOffsets[MemberIndex + 1];
99 if (SrcInRange.
getLower() != MemberStart ||
111 std::vector<GlobalVariable *> SplitGlobals(
Init->getNumOperands());
112 for (
unsigned I = 0;
I !=
Init->getNumOperands(); ++
I) {
118 SplitGlobals[
I] = SplitGV;
121 unsigned SplitEnd = (
I ==
Init->getNumOperands() - 1)
128 uint64_t ByteOffset = cast<ConstantInt>(
129 cast<ConstantAsMetadata>(
Type->getOperand(0))->getValue())
139 uint64_t AttachedTo = (ByteOffset == 0) ? ByteOffset : ByteOffset - 1;
140 if (AttachedTo < SplitBegin || AttachedTo >= SplitEnd)
142 SplitGV->addMetadata(
143 LLVMContext::MD_type,
145 {ConstantAsMetadata::get(
146 ConstantInt::get(Int32Ty, ByteOffset - SplitBegin)),
147 Type->getOperand(1)}));
150 if (GV.
hasMetadata(LLVMContext::MD_vcall_visibility))
154 for (
const GEPInfo &
Info : Infos) {
155 assert(
Info.MemberIndex < SplitGlobals.size() &&
"Invalid member");
159 Info.GEP->isInBounds());
160 Info.GEP->replaceAllUsesWith(NewGEP);
180 &M, Intrinsic::type_checked_load_relative);
181 if ((!TypeTestFunc || TypeTestFunc->
use_empty()) &&
182 (!TypeCheckedLoadFunc || TypeCheckedLoadFunc->
use_empty()) &&
183 (!TypeCheckedLoadRelativeFunc ||
184 TypeCheckedLoadRelativeFunc->
use_empty()))
187 bool Changed =
false;
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
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.
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Class for arbitrary precision integers.
uint64_t getZExtValue() const
Get zero extended value.
bool uge(const APInt &RHS) const
Unsigned greater or equal comparison.
A container for analyses that lazily runs them and caches their results.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, GEPNoWrapFlags NW=GEPNoWrapFlags::none(), std::optional< ConstantRange > InRange=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
This class represents a range of values.
const APInt & getLower() const
Return the lower value for this range.
const APInt & getUpper() const
Return the upper value for this range.
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
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.
VCallVisibility getVCallVisibility() const
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
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.
const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
@ 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.
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.
reference emplace_back(ArgTypes &&... Args)
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
MutableArrayRef< TypeSize > getMemberOffsets()
unsigned getElementContainingOffset(uint64_t FixedOffset) const
Given a valid byte offset into the structure, returns the structure index that contains it.
TypeSize getElementOffset(unsigned Idx) const
The instances of the Type class are immutable: once they are created, they are never changed.
static IntegerType * getInt8Ty(LLVMContext &C)
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.
Function * getDeclarationIfExists(Module *M, ID id, ArrayRef< Type * > Tys, FunctionType *FT=nullptr)
This version supports overloaded intrinsics.
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...