50 bool doInitialization(
Module &M)
override;
72 GCMachineCodeAnalysis();
94 StringRef LowerIntrinsics::getPassName()
const {
95 return "Lower Garbage Collection Instructions";
98 void LowerIntrinsics::getAnalysisUsage(
AnalysisUsage &AU)
const {
99 FunctionPass::getAnalysisUsage(AU);
105 bool LowerIntrinsics::doInitialization(
Module &M) {
107 assert(
MI &&
"LowerIntrinsics didn't require GCModuleInfo!?");
109 if (!
I->isDeclaration() &&
I->hasGC())
110 MI->getFunctionInfo(*
I);
129 if (isa<AllocaInst>(
I) || isa<GetElementPtrInst>(
I) || isa<StoreInst>(
I) ||
134 if (
CallInst *CI = dyn_cast<CallInst>(
I))
135 if (
Function *
F = CI->getCalledFunction())
137 if (IID == Intrinsic::gcroot)
146 while (isa<AllocaInst>(IP))
154 dyn_cast<AllocaInst>(
SI->getOperand(1)->stripPointerCasts()))
158 bool MadeChange =
false;
163 ConstantPointerNull::get(cast<PointerType>(
Root->getAllocatedType())),
181 return DoLowering(
F, S);
194 bool MadeChange =
false;
202 switch (
F->getIntrinsicID()) {
204 case Intrinsic::gcwrite: {
213 case Intrinsic::gcread: {
222 case Intrinsic::gcroot: {
244 "Analyze Machine Code For Garbage Collection",
false,
false)
248 void GCMachineCodeAnalysis::getAnalysisUsage(
AnalysisUsage &AU)
const {
249 MachineFunctionPass::getAnalysisUsage(AU);
268 MCSymbol *
Label = InsertLabel(*CI->getParent(), RAI, CI->getDebugLoc());
281 if (
MI->isTerminator())
289 assert(TFI &&
"TargetRegisterInfo not available!");
300 assert(!FrameOffset.getScalable() &&
301 "Frame offsets with a scalable component are not supported");
302 RI->StackOffset = FrameOffset.getFixed();
308 bool GCMachineCodeAnalysis::runOnMachineFunction(
MachineFunction &MF) {
313 FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.
getFunction());
329 FindStackOffsets(MF);
INITIALIZE_PASS(GCMachineCodeAnalysis, "gc-analysis", "Analyze Machine Code For Garbage Collection", false, false) GCMachineCodeAnalysis
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
This class represents lattice values for constants.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module.
static bool InsertRootInitializers(Function &F, ArrayRef< AllocaInst * > Roots)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
void push_back(const T &Elt)
This class represents a function call, abstracting a target machine's calling convention.
static bool CouldBecomeSafePoint(Instruction *I)
CouldBecomeSafePoint - Predicate to conservatively determine whether the instruction could introduce ...
An instruction for reading from memory.
Function & getFunction()
Return the LLVM function that this machine code represents.
Value * getArgOperand(unsigned i) const
AnalysisUsage & addRequired()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
FunctionPass * createGCLoweringPass()
GCLowering Pass - Used by gc.root to perform its default lowering operations.
void initializeLowerIntrinsicsPass(PassRegistry &)
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 ...
An analysis pass which caches information about the entire Module.
Type * getType() const
All values are typed, get the type of this value.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
virtual const TargetInstrInfo * getInstrInfo() const
void takeName(Value *V)
Transfer the name from V to this value.
TargetInstrInfo - Interface to description of machine instruction set.
MCContext & getContext() const
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static bool runOnFunction(Function &F, bool PostInlining)
roots_iterator roots_end()
Root(llvm::StringRef Name="")
LLVM Basic Block Representation.
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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...
roots_iterator removeStackRoot(roots_iterator position)
removeStackRoot - Removes a root.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
GCStrategy & getStrategy()
getStrategy - Return the GC strategy for the function.
Represent the analysis usage information of a pass.
void addSafePoint(MCSymbol *Label, const DebugLoc &DL)
addSafePoint - Notes the existence of a safe point.
FunctionPass class - This class is used to implement most global optimizations.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
rewrite statepoints for gc
roots_iterator roots_begin()
roots_begin/roots_end - Iterators for all roots in the function.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
std::vector< GCRoot >::iterator roots_iterator
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Module.h This file contains the declarations for the Module class.
Information about stack frame layout on the target.
void setPreservesAll()
Set by analyses that do not transform their input at all.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
GCStrategy describes a garbage collector algorithm's code generation requirements,...
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
char & GCMachineCodeAnalysisID
GCMachineCodeAnalysis - Target-independent pass to mark safe points in machine code.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
virtual const TargetFrameLowering * getFrameLowering() const
void setFrameSize(uint64_t S)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
LLVM Value Representation.
bool needsSafePoints() const
True if safe points need to be inferred on call sites.
StringRef - Represent a constant reference to a string, i.e.
Garbage collection metadata for a single function.
Legacy analysis pass which computes a DominatorTree.
INITIALIZE_PASS_BEGIN(LowerIntrinsics, "gc-lowering", "GC Lowering", false, false) FunctionPass *llvm
amdgpu printf runtime AMDGPU Printf lowering
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
Wrapper class representing virtual and physical registers.
A wrapper class for inspecting calls to intrinsic functions.
an instruction to allocate memory on the stack
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL