[llvm] d97d4d8 - [NFC][IR] Value: assert this->takeName(this)
Dmitry Vassiliev via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 13 10:48:40 PST 2022
Author: Dmitry Vassiliev
Date: 2022-02-13T21:47:37+03:00
New Revision: d97d4d8d754df16ae9e333c2b97af8e5993b759f
URL: https://github.com/llvm/llvm-project/commit/d97d4d8d754df16ae9e333c2b97af8e5993b759f
DIFF: https://github.com/llvm/llvm-project/commit/d97d4d8d754df16ae9e333c2b97af8e5993b759f.diff
LOG: [NFC][IR] Value: assert this->takeName(this)
Need to add an assert about this->takeName(this). This restriction is already documented, so this is just an NFC check.
Without this assertion (as prescribed by original comments for this API), name deletion or down-stream assert failures may occur in other routines: e.g. at the beginning of replaceAllUsesWith() below.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D119636
Added:
Modified:
llvm/lib/IR/Value.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 18aef37e20235..df286df5a96a9 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -377,6 +377,7 @@ void Value::setName(const Twine &NewName) {
}
void Value::takeName(Value *V) {
+ assert(V != this && "Illegal call to this->takeName(this)!");
ValueSymbolTable *ST = nullptr;
// If this value has a name, drop it.
if (hasName()) {
More information about the llvm-commits
mailing list