35 const char *getPassName()
const override;
39 bool doFinalization(
Module &M)
override;
44 "Create Garbage Collector Module Metadata",
false,
false)
49 : F(F), S(S), FrameSize(~0LL) {}
62 assert(!F.
isDeclaration() &&
"Can only get GCFunctionInfo for a definition!");
66 if (I != FInfoMap.
end())
70 Functions.push_back(make_unique<GCFunctionInfo>(F, *S));
79 GCStrategyList.clear();
90 const char *Printer::getPassName()
const {
91 return "Print Garbage Collector Information";
110 bool Printer::runOnFunction(
Function &
F) {
114 GCFunctionInfo *FD = &getAnalysis<GCModuleInfo>().getFunctionInfo(F);
120 OS <<
"\t" << RI->Num <<
"\t" << RI->StackOffset <<
"[sp]\n";
126 OS <<
"\t" << PI->Label->getName() <<
": " <<
DescKind(PI->Kind)
132 OS <<
" " << RI->Num;
144 bool Printer::doFinalization(
Module &M) {
145 GCModuleInfo *GMI = getAnalysisIfAvailable<GCModuleInfo>();
146 assert(GMI &&
"Printer didn't require GCModuleInfo?!");
153 auto NMI = GCStrategyMap.find(Name);
154 if (NMI != GCStrategyMap.end())
155 return NMI->getValue();
158 if (Name == Entry.getName()) {
159 std::unique_ptr<GCStrategy> S = Entry.instantiate();
161 GCStrategyMap[
Name] = S.get();
162 GCStrategyList.push_back(std::move(S));
163 return GCStrategyList.back().get();
172 const std::string
error = (
"unsupported GC: " +
Name).str() +
173 " (did you remember to link and initialize the CodeGen library?)";
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A Module instance is used to store all the information related to an LLVM module. ...
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
const char * getGC() const
PointKind
PointKind - Used to indicate whether the address of the call instruction or the address after the cal...
print alias Alias Set Printer
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
StringRef getName() const
Return a constant reference to the value's name.
std::vector< GCPoint >::iterator iterator
AnalysisUsage & addRequired()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
GCFunctionInfo & getFunctionInfo(const Function &F)
get - Look up function metadata.
An analysis pass which caches information about the entire Module.
static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler, std::error_code EC, const Twine &Message)
FunctionPass * createGCInfoPrinter(raw_ostream &OS)
Creates a pass to print GC metadata.
roots_iterator roots_end()
Instr is the return address of a call.
static iterator_range< iterator > entries()
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
roots_iterator roots_begin()
roots_begin/roots_end - Iterators for all roots in the function.
ImmutablePass class - This class is used to provide information that does not need to be run...
live_iterator live_begin(const iterator &p)
live_begin/live_end - Iterators for live roots at a given safe point.
GCStrategy * getGCStrategy(const StringRef Name)
Lookup the GCStrategy object associated with the given gc name.
void setPreservesAll()
Set by analyses that do not transform their input at all.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
iterator begin()
begin/end - Iterators for safe points.
GCStrategy describes a garbage collector algorithm's code generation requirements, and provides overridable hooks for those needs which cannot be abstractly described.
void clear()
clear - Resets the pass.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
void initializeGCModuleInfoPass(PassRegistry &)
iterator find(const KeyT &Val)
Instr is a call instruction.
const ARM::ArchExtKind Kind
const Function & getFunction() const
getFunction - Return the function to which this metadata applies.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
live_iterator live_end(const iterator &p)
Garbage collection metadata for a single function.
std::vector< GCRoot >::iterator roots_iterator
std::vector< GCRoot >::const_iterator live_iterator