27class PreserveLibCallsAndAsmUsed {
29 PreserveLibCallsAndAsmUsed(
const StringSet<> &AsmUndefinedRefs,
31 std::vector<GlobalValue *> &LLVMUsed)
32 : AsmUndefinedRefs(AsmUndefinedRefs),
TM(
TM), LLVMUsed(LLVMUsed) {}
34 void findInModule(
Module &TheModule) {
37 findLibCallsAndAsm(
F);
39 findLibCallsAndAsm(GV);
41 findLibCallsAndAsm(GA);
54 std::vector<GlobalValue *> &LLVMUsed;
65 for (
unsigned I = 0, E =
static_cast<unsigned>(LibFunc::NumLibFuncs);
69 Libcalls.
insert(TLI.getName(
F));
76 TM.getSubtargetImpl(
F)->getTargetLowering();
81 for (
unsigned I = 0, E =
static_cast<unsigned>(RTLIB::UNKNOWN_LIBCALL);
83 if (
const char *
Name =
105 if (isa<GlobalAlias>(GV)) {
106 auto *
A = cast<GlobalAlias>(&GV);
107 FuncAliasee = dyn_cast<Function>(
A->getAliasee());
109 if ((isa<Function>(GV) || FuncAliasee) && Libcalls.
count(GV.
getName())) {
110 LLVMUsed.push_back(&GV);
115 TM.getNameWithPrefix(Buffer, &GV,
Mangler);
116 if (AsmUndefinedRefs.
count(Buffer))
117 LLVMUsed.push_back(&GV);
125 std::vector<GlobalValue *> UsedValues;
126 PreserveLibCallsAndAsmUsed(AsmUndefinedRefs,
TM, UsedValues)
127 .findInModule(TheModule);
129 if (UsedValues.empty())
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Module.h This file contains the declarations for the Module class.
const char LLVMTargetMachineRef TM
pre isel intrinsic Pre ISel Intrinsic Lowering
static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
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.