add an optimization for the case where the src has no name
llvm-svn: 34174
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp
index af75323..30ca5c3 100644
--- a/llvm/lib/VMCore/Value.cpp
+++ b/llvm/lib/VMCore/Value.cpp
@@ -141,6 +141,12 @@
/// takeName - transfer the name from V to this value, setting V's name to
/// empty. It is an error to call V->takeName(V).
void Value::takeName(Value *V) {
+ if (!V->hasName()) {
+ if (hasName())
+ setName("");
+ return;
+ }
+
std::string Name = V->getName();
V->setName("");
setName(Name);