30#define DEBUG_TYPE "logical-sroa"
37 for (
User *U :
I.users()) {
53 for (
auto *U :
I->users()) {
60 while (!WorkList.
empty()) {
78 if (LI->getPointerOperand() == &SAI)
86 if (
SI->getPointerOperand() == &SAI)
100 if (SGEP->getNumIndices() == 0)
103 enqueueAllUsers(SGEP);
130 assert(Index->getZExtValue() < Output.
size());
131 Output[Index->getZExtValue()].
push_back(SGEP);
141 B.SetInsertPoint(
II);
143 if (
II->getIntrinsicID() == Intrinsic::lifetime_start) {
144 B.CreateLifetimeStart(V);
145 }
else if (
II->getIntrinsicID() == Intrinsic::lifetime_end) {
146 B.CreateLifetimeEnd(V);
160 B.SetInsertPoint(SGEP);
177 assert(PerFieldSGEP.size() == ST->getNumElements());
185 B.SetInsertPoint(&SAI);
187 B.CreateStructuredAlloca(ST->getElementType(FieldIndex)));
189 for (
auto II : LifetimeIntrinsics)
196 for (
auto *
II : LifetimeIntrinsics)
197 II->eraseFromParent();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseSet and SmallDenseSet classes.
This header defines various interfaces for pass management in LLVM.
iv Induction Variable Users
static bool runLogicalSROA(Function &F)
static SmallVector< LifetimeIntrinsic * > collectLifetimeIntrinsicsUsing(Instruction &I)
static bool runOnStructuredAlloca(StructuredAllocaInst &SAI)
static void rewriteSGEPChain(IRBuilder<> &B, StructuredGEPInst *SGEP, StructuredAllocaInst *FieldAlloca)
static SmallVector< SmallVector< StructuredGEPInst * > > collectPerFieldSGEP(StructuredAllocaInst &SAI)
static bool isAllocaSplittable(StructuredAllocaInst &SAI)
static void copyLifetimeIntrinsicFor(IRBuilder<> &B, LifetimeIntrinsic *II, Value *V)
This file provides the interface for LLVM's Logical Scalar Replacement of Aggregates pass.
uint64_t IntrinsicInst * II
This file defines the SmallVector class.
LLVM Basic Block Representation.
Represents analyses that only rely on functions' control flow.
This is the shared class of boolean and integer constants.
Implements a dense probed hash-table based set.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
This is the common base class for lifetime intrinsics.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Class to represent struct types.
Type * getAllocationType() const
iterator_range< op_iterator > indices()
unsigned getNumIndices() const
LLVM Value Representation.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
iterator_range< user_iterator > users()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.