75 GCMachineCodeAnalysis();
107char LowerIntrinsics::ID = 0;
114StringRef LowerIntrinsics::getPassName()
const {
115 return "Lower Garbage Collection Instructions";
118void LowerIntrinsics::getAnalysisUsage(
AnalysisUsage &AU)
const {
119 FunctionPass::getAnalysisUsage(AU);
125bool LowerIntrinsics::doInitialization(
Module &M) {
127 assert(
MI &&
"LowerIntrinsics didn't require GCModuleInfo!?");
129 if (!
F.isDeclaration() &&
F.hasGC())
130 MI->getFunctionInfo(
F);
149 if (isa<AllocaInst>(
I) || isa<GetElementPtrInst>(
I) || isa<StoreInst>(
I) ||
154 if (
CallInst *CI = dyn_cast<CallInst>(
I))
155 if (
Function *
F = CI->getCalledFunction())
157 if (IID == Intrinsic::gcroot)
166 while (isa<AllocaInst>(IP))
172 if (
StoreInst *SI = dyn_cast<StoreInst>(IP))
174 dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
178 bool MadeChange =
false;
181 if (!InitedRoots.
count(Root)) {
184 Root, std::next(Root->getIterator()));
193bool LowerIntrinsics::runOnFunction(
Function &
F) {
207 bool MadeChange =
false;
215 switch (
F->getIntrinsicID()) {
217 case Intrinsic::gcwrite: {
226 case Intrinsic::gcread: {
236 case Intrinsic::gcroot: {
254char GCMachineCodeAnalysis::ID = 0;
258 "Analyze Machine Code For Garbage Collection",
false,
false)
262void GCMachineCodeAnalysis::getAnalysisUsage(
AnalysisUsage &AU)
const {
282 MCSymbol *
Label = InsertLabel(*CI->getParent(), RAI, CI->getDebugLoc());
294 if (
MI.isTerminator())
302 assert(TFI &&
"TargetRegisterInfo not available!");
313 assert(!FrameOffset.getScalable() &&
314 "Frame offsets with a scalable component are not supported");
315 RI->StackOffset = FrameOffset.getFixed();
326 FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.
getFunction());
333 const bool DynamicFrameSize =
342 FindStackOffsets(MF);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Analysis containing CSE Info
static bool InsertRootInitializers(Function &F, ArrayRef< AllocaInst * > Roots)
static bool CouldBecomeSafePoint(Instruction *I)
CouldBecomeSafePoint - Predicate to conservatively determine whether the instruction could introduce ...
static bool DoLowering(Function &F, GCStrategy &S)
Lower barriers out of existence (if the associated GCStrategy hasn't already done so....
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
pre isel intrinsic lowering
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
an instruction to allocate memory on the stack
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
InstListType::iterator iterator
Instruction iterators...
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
Value * getArgOperand(unsigned i) const
This class represents a function call, abstracting a target machine's calling convention.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Analysis pass which computes a DominatorTree.
Legacy analysis pass which computes a DominatorTree.
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
An analysis pass which caches information about the Function.
Garbage collection metadata for a single function.
void setFrameSize(uint64_t S)
void addSafePoint(MCSymbol *Label, const DebugLoc &DL)
addSafePoint - Notes the existence of a safe point.
std::vector< GCRoot >::iterator roots_iterator
roots_iterator removeStackRoot(roots_iterator position)
removeStackRoot - Removes a root.
GCStrategy & getStrategy()
getStrategy - Return the GC strategy for the function.
roots_iterator roots_end()
roots_iterator roots_begin()
roots_begin/roots_end - Iterators for all roots in the function.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
An analysis pass which caches information about the entire Module.
GCStrategy describes a garbage collector algorithm's code generation requirements,...
bool needsSafePoints() const
True if safe points need to be inferred on call sites.
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
A wrapper class for inspecting calls to intrinsic functions.
An instruction for reading from memory.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MCContext & getContext() const
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual bool doInitialization(Module &)
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
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.
void preserve()
Mark an analysis as preserved.
Wrapper class representing virtual and physical registers.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
Information about stack frame layout on the target.
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetFrameLowering * getFrameLowering() const
virtual const TargetInstrInfo * getInstrInfo() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
void takeName(Value *V)
Transfer the name from V to this value.
self_iterator getIterator()
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
char & GCMachineCodeAnalysisID
GCMachineCodeAnalysis - Target-independent pass to mark safe points in machine code.
FunctionPass * createGCLoweringPass()
GCLowering Pass - Used by gc.root to perform its default lowering operations.
char & GCLoweringID
GCLowering Pass - Used by gc.root to perform its default lowering operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
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...
void initializeLowerIntrinsicsPass(PassRegistry &)