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));
74 for (
const Function &F : TheModule) {
78 if (Lowering && TLSet.
insert(Lowering).second)
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);
109 if ((isa<Function>(GV) || FuncAliasee) && Libcalls.
count(GV.
getName())) {
110 LLVMUsed.push_back(&GV);
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())
void appendToCompilerUsed(Module &M, ArrayRef< GlobalValue *> Values)
Adds global values to the llvm.compiler.used list.
bool hasPrivateLinkage() const
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
virtual const TargetLowering * getTargetLowering() const
Implementation of the target library information.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
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.
const Triple & getTargetTriple() const
std::pair< typename base::iterator, bool > insert(StringRef Key)
Triple - Helper class for working with autoconf configuration names.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
Provides information about what library functions are available for the current target.
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
StringRef getName() const
Return a constant reference to the value's name.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
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...
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
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.
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.