50 bool doInitialization(
Module &M)
override;
73 GCMachineCodeAnalysis();
95 StringRef LowerIntrinsics::getPassName()
const {
96 return "Lower Garbage Collection Instructions";
99 void LowerIntrinsics::getAnalysisUsage(
AnalysisUsage &AU)
const {
106 bool LowerIntrinsics::doInitialization(
Module &M) {
108 assert(MI &&
"LowerIntrinsics didn't require GCModuleInfo!?");
110 if (!
I->isDeclaration() &&
I->hasGC())
130 if (isa<AllocaInst>(I) || isa<GetElementPtrInst>(I) || isa<StoreInst>(I) ||
135 if (
CallInst *CI = dyn_cast<CallInst>(I))
136 if (
Function *
F = CI->getCalledFunction())
147 while (isa<AllocaInst>(IP))
155 dyn_cast<AllocaInst>(
SI->getOperand(1)->stripPointerCasts()))
159 bool MadeChange =
false;
162 if (!InitedRoots.
count(Root)) {
180 GCFunctionInfo &FI = getAnalysis<GCModuleInfo>().getFunctionInfo(F);
183 return DoLowering(F, S);
196 bool MadeChange =
false;
246 "Analyze Machine Code For Garbage Collection",
false,
false)
250 void GCMachineCodeAnalysis::getAnalysisUsage(
AnalysisUsage &AU)
const {
261 BuildMI(MBB, MI, DL,
TII->get(TargetOpcode::GC_LABEL)).addSym(Label);
271 MCSymbol *Label = InsertLabel(*CI->getParent(), RAI, CI->getDebugLoc());
272 FI->addSafePoint(Label, CI->getDebugLoc());
284 if (MI->isTerminator())
292 assert(TFI &&
"TargetRegisterInfo not available!");
295 RI != FI->roots_end();) {
298 RI = FI->removeStackRoot(RI);
308 bool GCMachineCodeAnalysis::runOnMachineFunction(
MachineFunction &MF) {
313 FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.
getFunction());
314 MMI = &getAnalysis<MachineModuleInfo>();
326 if (FI->getStrategy().needsSafePoints())
330 FindStackOffsets(MF);
INITIALIZE_PASS(GCMachineCodeAnalysis, "gc-analysis", "Analyze Machine Code For Garbage Collection", false, false) GCMachineCodeAnalysis
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.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
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. ...
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
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)
static bool InsertRootInitializers(Function &F, ArrayRef< AllocaInst *> Roots)
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.
iterator begin()
Instruction iterator methods.
Value * getArgOperand(unsigned i) const
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
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.
GCFunctionInfo & getFunctionInfo(const Function &F)
get - Look up function metadata.
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.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
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
const BasicBlock & getEntryBlock() 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)
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
LLVM Basic Block Representation.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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.
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
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
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.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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, and provides overridable hooks for those needs which cannot be abstractly described.
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.
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction...
virtual const TargetFrameLowering * getFrameLowering() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
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.
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
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
A wrapper class for inspecting calls to intrinsic functions.
This class contains meta information specific to a module.
an instruction to allocate memory on the stack