53 unsigned IndexWidth =
DL.getIndexTypeSizeInBits(GV.
getType());
60 APInt MemberRelativeOffset;
63 :
GEP(
GEP), MemberIndex(MemberIndex),
64 MemberRelativeOffset(std::move(MemberRelativeOffset)) {}
68 auto *
GEP = dyn_cast<GEPOperator>(U);
72 std::optional<ConstantRange>
InRange =
GEP->getInRange();
92 unsigned MemberIndex =
94 TypeSize MemberStart = MemberOffsets[MemberIndex];
95 TypeSize MemberEnd = MemberIndex == MemberOffsets.
size() - 1
97 : MemberOffsets[MemberIndex + 1];
100 if (SrcInRange.
getLower() != MemberStart ||
112 std::vector<GlobalVariable *> SplitGlobals(
Init->getNumOperands());
113 for (
unsigned I = 0;
I !=
Init->getNumOperands(); ++
I) {
119 SplitGlobals[
I] = SplitGV;
122 unsigned SplitEnd = (
I ==
Init->getNumOperands() - 1)
129 uint64_t ByteOffset = cast<ConstantInt>(
130 cast<ConstantAsMetadata>(
Type->getOperand(0))->getValue())
140 uint64_t AttachedTo = (ByteOffset == 0) ? ByteOffset : ByteOffset - 1;
141 if (AttachedTo < SplitBegin || AttachedTo >= SplitEnd)
143 SplitGV->addMetadata(
144 LLVMContext::MD_type,
146 {ConstantAsMetadata::get(
147 ConstantInt::get(Int32Ty, ByteOffset - SplitBegin)),
148 Type->getOperand(1)}));
151 if (GV.
hasMetadata(LLVMContext::MD_vcall_visibility))
155 for (
const GEPInfo &
Info : Infos) {
156 assert(
Info.MemberIndex < SplitGlobals.size() &&
"Invalid member");
160 Info.GEP->isInBounds());
161 Info.GEP->replaceAllUsesWith(NewGEP);
180 Function *TypeCheckedLoadRelativeFunc =
182 if ((!TypeTestFunc || TypeTestFunc->
use_empty()) &&
183 (!TypeCheckedLoadFunc || TypeCheckedLoadFunc->
use_empty()) &&
184 (!TypeCheckedLoadRelativeFunc ||
185 TypeCheckedLoadRelativeFunc->
use_empty()))
188 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)
static bool InRange(int64_t Value, unsigned short Shift, int LBound, int HBound)
Module.h This file contains the declarations for the Module class.
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.
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...