Go to the documentation of this file.
27 class PreserveLibCallsAndAsmUsed {
29 PreserveLibCallsAndAsmUsed(
const StringSet<> &AsmUndefinedRefs,
31 std::vector<GlobalValue *> &LLVMUsed)
32 : AsmUndefinedRefs(AsmUndefinedRefs),
TM(
TM), LLVMUsed(LLVMUsed) {}
34 void findInModule(
Module &TheModule) {
35 initializeLibCalls(TheModule);
37 findLibCallsAndAsm(
F);
39 findLibCallsAndAsm(GV);
41 findLibCallsAndAsm(GA);
54 std::vector<GlobalValue *> &LLVMUsed;
59 void initializeLibCalls(
const Module &TheModule) {
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())
This is an optimization pass for GlobalISel generic memory operations.
Triple - Helper class for working with autoconf configuration names.
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit.
Implementation of the target library information.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
std::pair< typename Base::iterator, bool > insert(StringRef key)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool hasPrivateLinkage() const
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
Primary interface to the complete machine description for the target machine.
A Module instance is used to store all the information related to an LLVM module.
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...
StringSet - A wrapper for StringMap that provides set-like functionality.
StringRef getName() const
Return a constant reference to the value's name.
Provides information about what library functions are available for the current target.
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
const char LLVMTargetMachineRef TM
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.