Replace calls of the form V1->setName(V2->getName()) with V1->takeName(V2),
authorOwen Anderson <resistor@mac.com>
Sun, 13 Apr 2008 19:15:17 +0000 (19:15 +0000)
committerOwen Anderson <resistor@mac.com>
Sun, 13 Apr 2008 19:15:17 +0000 (19:15 +0000)
which is significantly more efficient.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49614 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Linker/LinkModules.cpp
lib/Transforms/Scalar/LoopRotation.cpp
lib/Transforms/Scalar/LoopUnroll.cpp
lib/Transforms/Scalar/TailDuplication.cpp
lib/Transforms/Utils/CodeExtractor.cpp
tools/bugpoint/Miscompilation.cpp

index a82b266bbdb09e7b2e8876219632add8c4a37136..7aa169c4c468789cb4632780dd901f23aaafb313 100644 (file)
@@ -930,7 +930,7 @@ static bool LinkFunctionBody(Function *Dest, Function *Src,
   Function::arg_iterator DI = Dest->arg_begin();
   for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();
        I != E; ++I, ++DI) {
-    DI->setName(I->getName());  // Copy the name information over...
+    DI->takeName(I);  // Copy the name information over...
 
     // Add a mapping to our local map
     ValueMap[I] = DI;
index 51e2cd8900c2aec82ffb7801297078a0308151e9..53473fdfd37296d3f931987dcb23400962551de3 100644 (file)
@@ -226,7 +226,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
     // If this instruction is using a value from same basic block then
     // update it to use value from cloned instruction.
     Instruction *C = In->clone();
-    C->setName(In->getName());
+    C->takeName(In);
     OrigPreHeader->getInstList().push_back(C);
 
     for (unsigned opi = 0, e = In->getNumOperands(); opi != e; ++opi) {
index 1962c14d5d6c64ad669054da0760d99ee8501221..a3c58f75c5bbbf3ce146825eddc0d0dca4507636 100644 (file)
@@ -179,8 +179,8 @@ BasicBlock *LoopUnroll::FoldBlockIntoPredecessor(BasicBlock *BB) {
   BB->eraseFromParent();
 
   // Inherit predecessor's name if it exists...
-  if (!OldName.empty() && !OnlyPred->hasName())
-    OnlyPred->setName(OldName);
+  if (BB->hasName() && !OnlyPred->hasName())
+    OnlyPred->takeName(BB);
 
   return OnlyPred;
 }
index 929d11374506ea0f9128db8731fce7f59354b3d1..5d802a6e7a70bba8318466e5fac2c150aaf333f8 100644 (file)
@@ -317,7 +317,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
   //
   for (; BI != DestBlock->end(); ++BI) {
     Instruction *New = BI->clone();
-    New->setName(BI->getName());
+    New->takeName(BI);
     SourceBlock->getInstList().push_back(New);
     ValueMapping[BI] = New;
   }
index 54341196fb5856f39e72d30d1f47dc585de72adb..b21683b237ab000c01a2d978b6c8d98281b97c69 100644 (file)
@@ -317,7 +317,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
   if (!AggregateArgs) {
     AI = newFunction->arg_begin();
     for (unsigned i = 0, e = inputs.size(); i != e; ++i, ++AI)
-      AI->setName(inputs[i]->getName());
+      AI->takeName(inputs[i]);
     for (unsigned i = 0, e = outputs.size(); i != e; ++i, ++AI)
       AI->setName(outputs[i]->getName()+".out");
   }
index 536c3dbd744c0fae284a78802332fe2372bd3d5d..47d90e51ef3d83c2223800adf16936d085605c92 100644 (file)
@@ -657,7 +657,7 @@ static void CleanupAndPrepareModules(BugDriver &BD, Module *&Test,
       for (Function::arg_iterator
              I = newMain->arg_begin(), E = newMain->arg_end(),
              OI = oldMain->arg_begin(); I != E; ++I, ++OI) {
-        I->setName(OI->getName());    // Copy argument names from oldMain
+        I->takeName(OI);    // Copy argument names from oldMain
         args.push_back(I);
       }