[llvm] 27b53e9 - llvm-reduce: Use takeName instead of setName when cloning functions (#133393)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 28 16:53:23 PDT 2025
Author: Matt Arsenault
Date: 2025-03-29T06:53:21+07:00
New Revision: 27b53e90a50428456e48a04b606fc366d48520a9
URL: https://github.com/llvm/llvm-project/commit/27b53e90a50428456e48a04b606fc366d48520a9
DIFF: https://github.com/llvm/llvm-project/commit/27b53e90a50428456e48a04b606fc366d48520a9.diff
LOG: llvm-reduce: Use takeName instead of setName when cloning functions (#133393)
Added:
Modified:
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
index bf9d6ba145f6f..b16f512ff6166 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp
@@ -168,15 +168,13 @@ static void extractArgumentsFromModule(Oracle &O, ReducerWorkItem &WorkItem) {
auto *ClonedFunc = CloneFunction(F, VMap);
// In order to preserve function order, we move Clone after old Function
+ ClonedFunc->takeName(F);
ClonedFunc->removeFromParent();
Program.getFunctionList().insertAfter(F->getIterator(), ClonedFunc);
replaceFunctionCalls(*F, *ClonedFunc, ArgIndexesToKeep);
- // Rename Cloned Function to Old's name
- std::string FName = std::string(F->getName());
F->replaceAllUsesWith(ClonedFunc);
F->eraseFromParent();
- ClonedFunc->setName(FName);
}
}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
index 66d4bd3048171..32bceb74afa70 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
@@ -184,11 +184,9 @@ static void substituteOperandWithArgument(Function *OldF,
// Replace all OldF uses with NewF.
replaceFunctionCalls(OldF, NewF);
- // Rename NewF to OldF's name.
- std::string FName = OldF->getName().str();
+ NewF->takeName(OldF);
OldF->replaceAllUsesWith(NewF);
OldF->eraseFromParent();
- NewF->setName(FName);
}
static void reduceOperandsToArgs(Oracle &O, ReducerWorkItem &WorkItem) {
More information about the llvm-commits
mailing list