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 {
113 bool LowerIntrinsics::doInitialization(
Module &M) {
115 assert(MI &&
"LowerIntrinsics didn't require GCModuleInfo!?");
117 if (!
I->isDeclaration() &&
I->hasGC())
137 if (isa<AllocaInst>(I) || isa<GetElementPtrInst>(I) || isa<StoreInst>(I) ||
142 if (
CallInst *CI = dyn_cast<CallInst>(I))
143 if (
Function *
F = CI->getCalledFunction())
145 if (IID == Intrinsic::gcroot)
155 while (isa<AllocaInst>(IP))
163 dyn_cast<AllocaInst>(
SI->getOperand(1)->stripPointerCasts()))
167 bool MadeChange =
false;
170 if (!InitedRoots.
count(*
I)) {
188 GCFunctionInfo &FI = getAnalysis<GCModuleInfo>().getFunctionInfo(F);
191 bool MadeChange =
false;
194 MadeChange |= PerformDefaultLowering(F, S);
206 bool MadeChange =
false;
210 Function *F = CI->getCalledFunction();
212 case Intrinsic::gcwrite:
216 new StoreInst(CI->getArgOperand(0), CI->getArgOperand(2), CI);
218 CI->eraseFromParent();
221 case Intrinsic::gcread:
226 CI->replaceAllUsesWith(Ld);
227 CI->eraseFromParent();
230 case Intrinsic::gcroot:
235 cast<AllocaInst>(CI->getArgOperand(0)->stripPointerCasts()));
259 "Analyze Machine Code For Garbage Collection",
false,
false)
263 void GCMachineCodeAnalysis::getAnalysisUsage(
AnalysisUsage &AU)
const {
274 BuildMI(MBB, MI, DL,
TII->get(TargetOpcode::GC_LABEL)).addSym(Label);
284 if (FI->getStrategy().needsSafePoint(
GC::PreCall)) {
285 MCSymbol *Label = InsertLabel(*CI->getParent(), CI, CI->getDebugLoc());
286 FI->addSafePoint(
GC::PreCall, Label, CI->getDebugLoc());
290 MCSymbol *Label = InsertLabel(*CI->getParent(), RAI, CI->getDebugLoc());
291 FI->addSafePoint(
GC::PostCall, Label, CI->getDebugLoc());
305 if (MI->isTerminator())
313 assert(TFI &&
"TargetRegisterInfo not available!");
316 RI != FI->roots_end();) {
319 RI = FI->removeStackRoot(RI);
329 bool GCMachineCodeAnalysis::runOnMachineFunction(
MachineFunction &MF) {
334 FI = &getAnalysis<GCModuleInfo>().getFunctionInfo(MF.
getFunction());
335 MMI = &getAnalysis<MachineModuleInfo>();
347 if (FI->getStrategy().needsSafePoints())
351 FindStackOffsets(MF);
INITIALIZE_PASS(GCMachineCodeAnalysis, "gc-analysis", "Analyze Machine Code For Garbage Collection", false, false) GCMachineCodeAnalysis
void push_back(const T &Elt)
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...
Compute iterated dominance frontiers using a linear time algorithm.
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.
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.
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.
bool customReadBarrier() const
By default, read barriers are replaced with simple load instructions.
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...
bool customWriteBarrier() const
By default, write barriers are replaced with simple store instructions.
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.
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")
Instr is the return address of a call.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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
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.
static bool NeedsDefaultLoweringPass(const GCStrategy &C)
void setPreservesAll()
Set by analyses that do not transform their input at all.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static bool InsertRootInitializers(Function &F, AllocaInst **Roots, unsigned Count)
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.
bool initializeRoots() const
If set, gcroot intrinsics should initialize their allocas to null before the first use...
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction...
virtual const TargetFrameLowering * getFrameLowering() const
Instr is a call instruction.
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