32 ModuleHasher(
Module &M) : TheModule(M) {}
41 for (
auto &
F : TheModule) {
42 if (
F.isDeclaration() ||
F.hasLocalLinkage() || !
F.hasName())
44 auto Name =
F.getName();
47 for (
auto &GV : TheModule.globals()) {
48 if (GV.isDeclaration() || GV.hasLocalLinkage() || !GV.hasName())
59 TheHash = Result.
str();
73 GV.setName(
Twine(
"anon.") + ModuleHash.get() +
"." +
Twine(count++));
87 class NameAnonGlobalLegacyPass :
public ModulePass {
94 StringRef getPassName()
const override {
return "Name Anon Globals"; }
96 explicit NameAnonGlobalLegacyPass() :
ModulePass(ID) {}
113 "Provide a name to nameless globals",
false,
false)
115 "Provide a
name to nameless globals",
false, false)
119 return new NameAnonGlobalLegacyPass();
ModulePass * createNameAnonGlobalPass()
===------------------------------------------------------------------—===//
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
static void stringifyResult(MD5Result &Result, SmallString< 32 > &Str)
Translates the bytes in Res to a hex string that is deposited into Str.
INITIALIZE_PASS_BEGIN(NameAnonGlobalLegacyPass, "name-anon-globals", "Provide a name to nameless globals", false, false) INITIALIZE_PASS_END(NameAnonGlobalLegacyPass
bool nameUnamedGlobals(Module &M)
Rename all the anon globals in the module using a hash computed from the list of public globals in th...
iterator_range< global_object_iterator > global_objects()
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
StringRef str() const
Explicit conversion to StringRef.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
A set of analyses that are preserved following a run of a transformation pass.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
Module.h This file contains the declarations for the Module class.
StringRef getName() const
Return a constant reference to the value's name.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
StringRef - Represent a constant reference to a string, i.e.
A container for analyses that lazily runs them and caches their results.
iterator_range< alias_iterator > aliases()