diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -377,6 +377,10 @@ } void Value::takeName(Value *V) { + // 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. + assert(V != this && "Illegal call to this->takeName(this)!"); ValueSymbolTable *ST = nullptr; // If this value has a name, drop it. if (hasName()) {