Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions llvm/lib/IR/Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,16 @@ void Value::setNameImpl(const Twine &NewName) {
if (getSymTab(this, ST))
return; // Cannot set a name on this value (e.g. constant).

// Copy NewName forcely if the memory overlaps.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copy NewName forcely if the memory overlaps.
// Copy NewName if the memory overlaps.

or "forcefully", but I think you can just omit it.

if (!NameRef.empty()) {
StringRef OldNameRef = getName();
if ((OldNameRef.bytes_begin() < NameRef.bytes_end()) &&
(NameRef.bytes_begin() < OldNameRef.bytes_end())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is technically UB in the case where it doesn't overlap. One has to use std::less in this case.

NewName.toVector(NameData);
NameRef = StringRef(NameData.data(), NameData.size());
}
}

if (!ST) { // No symbol table to update? Just do the change.
// NOTE: Could optimize for the case the name is shrinking to not deallocate
// then reallocated.
Expand Down
Loading