aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/BasicBlockUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils/BasicBlockUtils.cpp')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index 769d1b2d78..f9bcd39e41 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -29,14 +29,12 @@ void llvm::ReplaceInstWithValue(BasicBlock::InstListType &BIL,
// Replaces all of the uses of the instruction with uses of the value
I.replaceAllUsesWith(V);
- std::string OldName = I.getName();
+ // Make sure to propagate a name if there is one already.
+ if (I.hasName() && !V->hasName())
+ V->takeName(&I);
// Delete the unnecessary instruction now...
BI = BIL.erase(BI);
-
- // Make sure to propagate a name if there is one already.
- if (!OldName.empty() && !V->hasName())
- V->setName(OldName);
}