Skip to content

Commit c1d5c08

Browse files
committed
llvm-reduce: Use splice and remap instead of clone
1 parent 5f66e48 commit c1d5c08

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

llvm/tools/llvm-reduce/deltas/ReduceValuesToReturn.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
#include "Utils.h"
2121
#include "llvm/IR/CFG.h"
2222
#include "llvm/IR/Instructions.h"
23+
#include "llvm/Support/Debug.h"
2324
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
24-
#include "llvm/Transforms/Utils/Cloning.h"
25+
#include "llvm/Transforms/Utils/ValueMapper.h"
2526

2627
using namespace llvm;
2728

@@ -121,6 +122,9 @@ static void rewriteFuncWithReturnType(Function &OldF, Value *NewRetValue) {
121122
}
122123
}
123124

125+
NewF->splice(NewF->begin(), &OldF);
126+
OldF.replaceAllUsesWith(NewF);
127+
124128
// Preserve the parameters of OldF.
125129
ValueToValueMapTy VMap;
126130
for (auto Z : zip_first(OldF.args(), NewF->args())) {
@@ -131,11 +135,8 @@ static void rewriteFuncWithReturnType(Function &OldF, Value *NewRetValue) {
131135
VMap[&OldArg] = &NewArg; // Add mapping to VMap
132136
}
133137

134-
SmallVector<ReturnInst *, 8> Returns; // Ignore returns cloned.
135-
CloneFunctionInto(NewF, &OldF, VMap,
136-
CloneFunctionChangeType::LocalChangesOnly, Returns, "",
137-
/*CodeInfo=*/nullptr);
138-
OldF.replaceAllUsesWith(NewF);
138+
RemapFunction(*NewF, VMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
139+
139140
OldF.eraseFromParent();
140141
}
141142

0 commit comments

Comments
 (0)