39 "rename-exclude-function-prefixes",
40 cl::desc(
"Prefixes for functions that don't need to be renamed, separated "
45 "rename-exclude-alias-prefixes",
46 cl::desc(
"Prefixes for aliases that don't need to be renamed, separated "
51 "rename-exclude-global-prefixes",
53 "Prefixes for global values that don't need to be renamed, separated "
58 "rename-exclude-struct-prefixes",
59 cl::desc(
"Prefixes for structs that don't need to be renamed, separated "
65 cl::desc(
"only rename the instructions in the function"),
70 "foo",
"bar",
"baz",
"quux",
"barney",
"snork",
"zot",
"blam",
"hoge",
71 "wibble",
"wobble",
"widget",
"wombat",
"ham",
"eggs",
"pluto",
"spam"
81 void srand(
unsigned int seed) { next = seed; }
84 next = next * 1103515245 + 12345;
85 return (
unsigned int)(next / 65536) % 32768;
90 Renamer(
unsigned int seed) { prng.srand(seed); }
92 const char *newName() {
100parseExcludedPrefixes(
StringRef PrefixesStr,
103 auto PrefixesSplit = PrefixesStr.
split(
',');
104 if (PrefixesSplit.first.empty())
106 ExcludedPrefixes.
push_back(PrefixesSplit.first);
107 PrefixesStr = PrefixesSplit.second;
111void MetaRenameOnlyInstructions(
Function &
F) {
113 if (!
I.getType()->isVoidTy() &&
I.getName().empty())
114 I.setName(
I.getOpcodeName());
119 if (!Arg.getType()->isVoidTy())
126 if (!
I.getType()->isVoidTy())
127 I.setName(
I.getOpcodeName());
136 unsigned int randSeed = 0;
137 for (
auto C : M.getModuleIdentifier())
140 Renamer renamer(randSeed);
153 return any_of(ExcludedPrefixes,
154 [&Name](
auto &Prefix) {
return Name.starts_with(Prefix); });
159 auto ExcludeLibFuncs = [&](
Function &
F) {
161 return F.isIntrinsic() || (!
Name.empty() && Name[0] == 1) ||
162 GetTLI(
F).getLibFunc(
F) != NotLibFunc ||
163 IsNameExcluded(Name, ExcludedFuncPrefixes);
169 if (ExcludeLibFuncs(
F))
171 MetaRenameOnlyInstructions(
F);
179 if (
Name.starts_with(
"llvm.") || (!
Name.empty() && Name[0] == 1) ||
180 IsNameExcluded(Name, ExcludedAliasesPrefixes))
189 if (
Name.starts_with(
"llvm.") || (!
Name.empty() && Name[0] == 1) ||
190 IsNameExcluded(Name, ExcludedGlobalsPrefixes))
193 GV.setName(
"global");
198 StructTypes.
run(M,
true);
201 if (STy->isLiteral() ||
Name.empty() ||
202 IsNameExcluded(Name, ExcludedStructsPrefixes))
207 (
Twine(
"struct.") + renamer.newName()).toStringRef(NameStorage));
212 if (ExcludeLibFuncs(
F))
217 if (
F.getName() !=
"main")
218 F.setName(renamer.newName());
232 MetaRename(M, GetTLI);
Expand Atomic instructions
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
FunctionAnalysisManager FAM
This file defines the SmallString class.
This file defines the SmallVector class.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This class represents an incoming formal argument to a Function.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Class to represent struct types.
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
TypeFinder - Walk over a module, identifying all of the types that are used by the module.
LLVM_ABI void run(const Module &M, bool onlyNamed)
An efficient, type-erasing, non-owning reference to a callable.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.