aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/IndVarSimplify.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-11 01:23:03 +0000
committerChris Lattner <sabre@nondot.org>2007-02-11 01:23:03 +0000
commit6934a04a8c15e9971cd1ea4d5c8df2d7afdd5be5 (patch)
tree23823b269e47b7026c27e2da4eb05b062db0b123 /lib/Transforms/Scalar/IndVarSimplify.cpp
parent046800a7125cd497613efc0e1ea15cb595666585 (diff)
Simplify code by using value::takename
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34176 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index 155e7ccb39..4d03f28c4b 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -195,10 +195,10 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
if (!PN->use_empty()) {
BasicBlock::iterator InsertPos = PN; ++InsertPos;
while (isa<PHINode>(InsertPos)) ++InsertPos;
- std::string Name = PN->getName(); PN->setName("");
Value *PreInc =
new GetElementPtrInst(PN->getIncomingValue(PreheaderIdx),
- NewPhi, Name, InsertPos);
+ NewPhi, "", InsertPos);
+ PreInc->takeName(PN);
PN->replaceAllUsesWith(PreInc);
}
@@ -556,9 +556,7 @@ void IndVarSimplify::runOnLoop(Loop *L) {
PN->getType());
DOUT << "INDVARS: Rewrote IV '" << *IndVars.back().second << "' " << *PN
<< " into = " << *NewVal << "\n";
- std::string Name = PN->getName();
- PN->setName("");
- NewVal->setName(Name);
+ NewVal->takeName(PN);
// Replace the old PHI Node with the inserted computation.
PN->replaceAllUsesWith(NewVal);
@@ -581,11 +579,8 @@ void IndVarSimplify::runOnLoop(Loop *L) {
SCEVHandle SH = SE->getSCEV(I);
Value *V = Rewriter.expandCodeFor(SH, I, I->getType());
if (V != I) {
- if (isa<Instruction>(V)) {
- std::string Name = I->getName();
- I->setName("");
- V->setName(Name);
- }
+ if (isa<Instruction>(V))
+ V->takeName(I);
I->replaceAllUsesWith(V);
DeadInsts.insert(I);
++NumRemoved;