15#include "llvm/Config/llvm-config.h"
30#define DEBUG_TYPE "valuesymtab"
35 for (
const auto &VI : vmap)
36 dbgs() <<
"Value still in symbol table! Type = '"
37 << *VI.getValue()->getType() <<
"' Name = '" << VI.getKeyData()
39 assert(vmap.empty() &&
"Values remain in symbol table!");
45 unsigned BaseSize = UniqueName.
size();
46 bool AppenDot =
false;
47 if (
auto *GV = dyn_cast<GlobalValue>(V)) {
54 const Module *M = GV->getParent();
61 UniqueName.
resize(BaseSize);
68 if (MaxNameSize > -1 && UniqueName.
size() > (
size_t)MaxNameSize) {
69 assert(BaseSize >= UniqueName.
size() - (
size_t)MaxNameSize &&
70 "Can't generate unique name: MaxNameSize is too small.");
71 BaseSize -= UniqueName.
size() - (size_t)MaxNameSize;
75 auto IterBool = vmap.
insert(std::make_pair(UniqueName.
str(), V));
77 return &*IterBool.first;
83void ValueSymbolTable::reinsertValue(
Value *V) {
84 assert(
V->hasName() &&
"Can't insert nameless Value into symbol table");
87 if (vmap.
insert(
V->getValueName())) {
98 V->getValueName()->Destroy(Allocator);
100 ValueName *VN = makeUniqueName(V, UniqueName);
104void ValueSymbolTable::removeValueName(
ValueName *V) {
114 if (MaxNameSize > -1 &&
Name.size() > (
unsigned)MaxNameSize)
115 Name =
Name.substr(0, std::max(1u, (
unsigned)MaxNameSize));
118 auto IterBool = vmap.
insert(std::make_pair(
Name, V));
119 if (IterBool.second) {
122 return &*IterBool.first;
127 return makeUniqueName(V, UniqueName);
130#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
135 for (
const auto &
I : *
this) {
137 I.getValue()->dump();
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
A Module instance is used to store all the information related to an LLVM module.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
void remove(MapEntryTy *KeyValue)
remove - Remove the specified key/value pair from the map, but do not erase it.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
Triple - Helper class for working with autoconf configuration names.
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
void dump() const
This function can be used from the debugger to display the content of the symbol table while debuggin...
LLVM Value Representation.
A raw_ostream that writes to an SmallVector or SmallString.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.