[llvm] 8134c2c - [AutoUpgrade] Simplify code

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 04:23:19 PDT 2020


Author: Benjamin Kramer
Date: 2020-08-11T13:22:58+02:00
New Revision: 8134c2c7ffed3b3b4bd340174ad3134f509ebd47

URL: https://github.com/llvm/llvm-project/commit/8134c2c7ffed3b3b4bd340174ad3134f509ebd47
DIFF: https://github.com/llvm/llvm-project/commit/8134c2c7ffed3b3b4bd340174ad3134f509ebd47.diff

LOG: [AutoUpgrade] Simplify code

No need to set the name on an instruction that's going away, just move
it from the old instruction to the new one.

Added: 
    

Modified: 
    llvm/lib/IR/AutoUpgrade.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index b3896823fcd0..dfe05c023b94 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -3720,11 +3720,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
     // Replace the original call result with the first result of the new call.
     Value *TSC = Builder.CreateExtractValue(NewCall, 0);
 
-    std::string Name = std::string(CI->getName());
-    if (!Name.empty()) {
-      CI->setName(Name + ".old");
-      NewCall->setName(Name);
-    }
+    NewCall->takeName(CI);
     CI->replaceAllUsesWith(TSC);
     CI->eraseFromParent();
     return;
@@ -3761,11 +3757,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
     NewCall = Builder.CreateCall(NewFn, Args);
     Value *Res = ApplyX86MaskOn1BitsVec(Builder, NewCall, nullptr);
 
-    std::string Name(CI->getName());
-    if (!Name.empty()) {
-      CI->setName(Name + ".old");
-      NewCall->setName(Name);
-    }
+    NewCall->takeName(CI);
     CI->replaceAllUsesWith(Res);
     CI->eraseFromParent();
     return;
@@ -3819,11 +3811,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {
   }
   assert(NewCall && "Should have either set this variable or returned through "
                     "the default case");
-  std::string Name = std::string(CI->getName());
-  if (!Name.empty()) {
-    CI->setName(Name + ".old");
-    NewCall->setName(Name);
-  }
+  NewCall->takeName(CI);
   CI->replaceAllUsesWith(NewCall);
   CI->eraseFromParent();
 }
@@ -4016,7 +4004,7 @@ void llvm::UpgradeARCRuntime(Module &M) {
       // Create a call instruction that calls the new function.
       CallInst *NewCall = Builder.CreateCall(NewFuncTy, NewFn, Args);
       NewCall->setTailCallKind(cast<CallInst>(CI)->getTailCallKind());
-      NewCall->setName(CI->getName());
+      NewCall->takeName(CI);
 
       // Bitcast the return value back to the type of the old call.
       Value *NewRetVal = Builder.CreateBitCast(NewCall, CI->getType());


        


More information about the llvm-commits mailing list