From 8dd4cae4f8816e3c498bbb2efdf4edf03d229bff Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 11 Feb 2007 01:37:51 +0000 Subject: simplify code by using Value::takeName llvm-svn: 34177 --- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Transforms/Utils/BasicBlockUtils.cpp') diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index 769d1b2d78e..f9bcd39e41c 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/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); } -- cgit v1.2.3