28 class PreserveLibCallsAndAsmUsed {
30 PreserveLibCallsAndAsmUsed(
const StringSet<> &AsmUndefinedRefs,
32 std::vector<GlobalValue *> &LLVMUsed)
33 : AsmUndefinedRefs(AsmUndefinedRefs), TM(TM), LLVMUsed(LLVMUsed) {}
35 void findInModule(
Module &TheModule) {
36 initializeLibCalls(TheModule);
38 findLibCallsAndAsm(F);
40 findLibCallsAndAsm(GV);
42 findLibCallsAndAsm(GA);
55 std::vector<GlobalValue *> &LLVMUsed;
60 void initializeLibCalls(
const Module &TheModule) {
70 Libcalls.insert(TLI.getName(F));
75 for (
const Function &F : TheModule) {
77 TM.getSubtargetImpl(F)->getTargetLowering();
79 if (Lowering && TLSet.
insert(Lowering).second)
84 if (
const char *
Name =
86 Libcalls.insert(
Name);
104 if (isa<Function>(GV) && Libcalls.count(GV.
getName())) {
105 LLVMUsed.push_back(&GV);
110 TM.getNameWithPrefix(Buffer, &GV,
Mangler);
111 if (AsmUndefinedRefs.count(Buffer))
112 LLVMUsed.push_back(&GV);
120 std::vector<GlobalValue *> UsedValues;
121 PreserveLibCallsAndAsmUsed(AsmUndefinedRefs, TM, UsedValues)
122 .findInModule(TheModule);
124 if (UsedValues.empty())
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue * > Values)
Adds global values to the llvm.compiler.used list.
A Module instance is used to store all the information related to an LLVM module. ...
Implementation of the target library information.
StringRef getName() const
Return a constant reference to the value's name.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool hasPrivateLinkage() const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Triple - Helper class for working with autoconf configuration names.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
shadow stack gc Shadow Stack GC Lowering
Provides information about what library functions are available for the current target.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
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.
Primary interface to the complete machine description for the target machine.
This file describes how to lower LLVM code to machine code.