68 GCMachineCodeAnalysis();
84char LowerIntrinsics::ID = 0;
91StringRef LowerIntrinsics::getPassName()
const {
92 return "Lower Garbage Collection Instructions";
95void LowerIntrinsics::getAnalysisUsage(
AnalysisUsage &AU)
const {
96 FunctionPass::getAnalysisUsage(AU);
102bool LowerIntrinsics::doInitialization(
Module &M) {
104 assert(
MI &&
"LowerIntrinsics didn't require GCModuleInfo!?");
106 if (!
F.isDeclaration() &&
F.hasGC())
107 MI->getFunctionInfo(
F);
126 if (isa<AllocaInst>(
I) || isa<GetElementPtrInst>(
I) || isa<StoreInst>(
I) ||
131 if (
CallInst *CI = dyn_cast<CallInst>(
I))
132 if (
Function *
F = CI->getCalledFunction())
134 if (IID == Intrinsic::gcroot)
143 while (isa<AllocaInst>(IP))
149 if (
StoreInst *SI = dyn_cast<StoreInst>(IP))
151 dyn_cast<AllocaInst>(SI->getOperand(1)->stripPointerCasts()))
155 bool MadeChange =
false;
158 if (!InitedRoots.
count(Root)) {
161 Root, Root->getNextNode());
170bool LowerIntrinsics::runOnFunction(
Function &
F) {
178 return DoLowering(
F, S);
191 bool MadeChange =
false;
199 switch (
F->getIntrinsicID()) {
201 case Intrinsic::gcwrite: {
210 case Intrinsic::gcread: {
219 case Intrinsic::gcroot: {
237char GCMachineCodeAnalysis::ID = 0;
241 "Analyze Machine Code For Garbage Collection",
false,
false)
245void GCMachineCodeAnalysis::getAnalysisUsage(
AnalysisUsage &AU)
const {
265 MCSymbol *
Label = InsertLabel(*CI->getParent(), RAI, CI->getDebugLoc());
277 if (
MI.isTerminator())
285 assert(TFI &&
"TargetRegisterInfo not available!");
296 assert(!FrameOffset.getScalable() &&
297 "Frame offsets with a scalable component are not supported");
298 RI->StackOffset = FrameOffset.getFixed();
309 FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.
getFunction());
316 const bool DynamicFrameSize =
325 FindStackOffsets(MF);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool InsertRootInitializers(Function &F, ArrayRef< AllocaInst * > Roots)
static bool CouldBecomeSafePoint(Instruction *I)
CouldBecomeSafePoint - Predicate to conservatively determine whether the instruction could introduce ...
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
#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
pre isel intrinsic Pre ISel Intrinsic Lowering
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
an instruction to allocate memory on the stack
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.
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...
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.
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.
SymbolTableList< Instruction >::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.
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.
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 &)