本文整理汇总了C++中ValueSymbolTable::createValueName方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueSymbolTable::createValueName方法的具体用法?C++ ValueSymbolTable::createValueName怎么用?C++ ValueSymbolTable::createValueName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueSymbolTable
的用法示例。
在下文中一共展示了ValueSymbolTable::createValueName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setName
void Value::setName(const Twine &NewName) {
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
NewName.toVector(NameData);
const char *NameStr = NameData.data();
unsigned NameLen = NameData.size();
// Name isn't changing?
if (getName() == StringRef(NameStr, NameLen))
return;
assert(getType() != Type::getVoidTy(getContext()) &&
"Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameLen == 0) {
// Free the name for this value.
Name->Destroy();
Name = 0;
return;
}
if (Name)
Name->Destroy();
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameStr, NameStr+NameLen);
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = 0;
if (NameLen == 0)
return;
}
// Name is changing to something new.
Name = ST->createValueName(StringRef(NameStr, NameLen), this);
}
示例2: setName
void Value::setName(const Twine &NewName) {
assert(SubclassID != MDStringVal &&
"Cannot set the name of MDString with this method!");
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
StringRef NameRef = NewName.toStringRef(NameData);
// Name isn't changing?
if (getName() == NameRef)
return;
assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameRef.empty()) {
// Free the name for this value.
Name->Destroy();
Name = 0;
return;
}
if (Name)
Name->Destroy();
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameRef.begin(), NameRef.end());
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = 0;
if (NameRef.empty())
return;
}
// Name is changing to something new.
Name = ST->createValueName(NameRef, this);
}
示例3: setNameImpl
void Value::setNameImpl(const Twine &NewName) {
// Fast-path: LLVMContext can be set to strip out non-GlobalValue names
if (getContext().shouldDiscardValueNames() && !isa<GlobalValue>(this))
return;
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
StringRef NameRef = NewName.toStringRef(NameData);
assert(NameRef.find_first_of(0) == StringRef::npos &&
"Null bytes are not allowed in names");
// Name isn't changing?
if (getName() == NameRef)
return;
assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameRef.empty()) {
// Free the name for this value.
destroyValueName();
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
destroyValueName();
// Create the new name.
setValueName(ValueName::Create(NameRef));
getValueName()->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(getValueName());
destroyValueName();
if (NameRef.empty())
return;
}
// Name is changing to something new.
setValueName(ST->createValueName(NameRef, this));
}
示例4: setName
void Value::setName(const char *NameStr, unsigned NameLen) {
if (NameLen == 0 && !hasName()) return;
assert(getType() != Type::VoidTy && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (!ST) { // No symbol table to update? Just do the change.
if (NameLen == 0) {
// Free the name for this value.
Name->Destroy();
Name = 0;
return;
}
if (Name) {
// Name isn't changing?
if (NameLen == Name->getKeyLength() &&
!memcmp(Name->getKeyData(), NameStr, NameLen))
return;
Name->Destroy();
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameStr, NameStr+NameLen);
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Name isn't changing?
if (NameLen == Name->getKeyLength() &&
!memcmp(Name->getKeyData(), NameStr, NameLen))
return;
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = 0;
if (NameLen == 0)
return;
}
// Name is changing to something new.
Name = ST->createValueName(NameStr, NameLen, this);
}
示例5: setName
void Value::setName(const Twine &NewName) {
assert(SubclassID != MDStringVal &&
"Cannot set the name of MDString with this method!");
// Fast path for common IRBuilder case of setName("") when there is no name.
if (NewName.isTriviallyEmpty() && !hasName())
return;
SmallString<256> NameData;
StringRef NameRef = NewName.toStringRef(NameData);
assert(NameRef.find_first_of(0) == StringRef::npos &&
"Null bytes are not allowed in names");
// Name isn't changing?
if (getName() == NameRef)
return;
assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
ValueSymbolTable *ST;
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).
if (Function *F = dyn_cast<Function>(this))
getContext().pImpl->IntrinsicIDCache.erase(F);
if (!ST) { // No symbol table to update? Just do the change.
if (NameRef.empty()) {
// Free the name for this value.
Name->Destroy();
Name = nullptr;
return;
}
if (Name)
Name->Destroy();
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
// Create the new name.
Name = ValueName::Create(NameRef);
Name->setValue(this);
return;
}
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
if (hasName()) {
// Remove old name.
ST->removeValueName(Name);
Name->Destroy();
Name = nullptr;
if (NameRef.empty())
return;
}
// Name is changing to something new.
Name = ST->createValueName(NameRef, this);
}