LLVM  14.0.0git
GCStrategy.cpp
Go to the documentation of this file.
1 //===- GCStrategy.cpp - Garbage Collector Description ---------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the policy object GCStrategy which describes the
10 // behavior of a given garbage collector.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/IR/GCStrategy.h"
15 
16 using namespace llvm;
17 
19 
20 GCStrategy::GCStrategy() = default;
21 
22 std::unique_ptr<GCStrategy> llvm::getGCStrategy(const StringRef Name) {
23  for (auto &S : GCRegistry::entries())
24  if (S.getName() == Name)
25  return S.instantiate();
26 
28  // In normal operation, the registry should not be empty. There should
29  // be the builtin GCs if nothing else. The most likely scenario here is
30  // that we got here without running the initializers used by the Registry
31  // itself and it's registration mechanism.
32  const std::string error =
33  std::string("unsupported GC: ") + Name.str() +
34  " (did you remember to link and initialize the library?)";
36  } else
37  report_fatal_error(std::string("unsupported GC: ") + Name.str());
38 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::Registry::end
static iterator end()
Definition: Registry.h:99
error
#define error(X)
Definition: SymbolRecordMapping.cpp:14
llvm::GCStrategy::GCStrategy
GCStrategy()
llvm::Registry::entries
static iterator_range< iterator > entries()
Definition: Registry.h:101
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
LLVM_INSTANTIATE_REGISTRY
#define LLVM_INSTANTIATE_REGISTRY(REGISTRY_CLASS)
Instantiate a registry class.
Definition: Registry.h:137
llvm::Registry
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:44
llvm::getGCStrategy
std::unique_ptr< GCStrategy > getGCStrategy(const StringRef Name)
Lookup the GCStrategy object associated with the given gc name.
Definition: GCStrategy.cpp:22
llvm::Registry::begin
static iterator begin()
GCStrategy.h