26class PreserveLibCallsAndAsmUsed {
28 PreserveLibCallsAndAsmUsed(
const StringSet<> &AsmUndefinedRefs,
30 std::vector<GlobalValue *> &LLVMUsed)
31 : AsmUndefinedRefs(AsmUndefinedRefs),
TM(
TM), LLVMUsed(LLVMUsed) {}
33 void findInModule(
Module &TheModule) {
34 initializeLibCalls(TheModule);
36 findLibCallsAndAsm(
F);
38 findLibCallsAndAsm(GV);
40 findLibCallsAndAsm(GA);
53 std::vector<GlobalValue *> &LLVMUsed;
58 void initializeLibCalls(
const Module &TheModule) {
64 for (
unsigned I = 0,
E =
static_cast<unsigned>(LibFunc::NumLibFuncs);
68 Libcalls.
insert(TLI.getName(
F));
75 TM.getSubtargetImpl(
F)->getTargetLowering();
80 for (
unsigned I = 0,
E =
static_cast<unsigned>(RTLIB::UNKNOWN_LIBCALL);
82 if (
const char *
Name =
104 if (isa<GlobalAlias>(GV)) {
105 auto *
A = cast<GlobalAlias>(&GV);
106 FuncAliasee = dyn_cast<Function>(
A->getAliasee());
108 if ((isa<Function>(GV) || FuncAliasee) && Libcalls.
count(GV.
getName())) {
109 LLVMUsed.push_back(&GV);
114 TM.getNameWithPrefix(Buffer, &GV,
Mangler);
115 if (AsmUndefinedRefs.
count(Buffer))
116 LLVMUsed.push_back(&GV);
124 std::vector<GlobalValue *> UsedValues;
125 PreserveLibCallsAndAsmUsed(AsmUndefinedRefs,
TM, UsedValues)
126 .findInModule(TheModule);
128 if (UsedValues.empty())
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const char LLVMTargetMachineRef TM
pre isel intrinsic Pre ISel Intrinsic Lowering
This file describes how to lower LLVM code to machine code.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool hasPrivateLinkage() const
A Module instance is used to store all the information related to an LLVM module.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
StringSet - A wrapper for StringMap that provides set-like functionality.
std::pair< typename Base::iterator, bool > insert(StringRef key)
Implementation of the target library information.
Provides information about what library functions are available for the current target.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
StringRef getName() const
Return a constant reference to the value's name.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit.
This is an optimization pass for GlobalISel generic memory operations.
void updateCompilerUsed(Module &TheModule, const TargetMachine &TM, const StringSet<> &AsmUndefinedRefs)
Find all globals in TheModule that are referenced in AsmUndefinedRefs, as well as the user-supplied f...
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.