Skip to content

Commit 021b799

Browse files
author
Peter Goodman
authored
Exposes an internal function that can replace uses of a constant in a module (#497)
1 parent c37180a commit 021b799

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

include/remill/BC/Util.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace llvm {
4444
class Argument;
4545
class BasicBlock;
4646
class CallInst;
47+
class Constant;
4748
class Function;
4849
class FunctionType;
4950
class GlobalObject;
@@ -248,6 +249,13 @@ std::vector<llvm::CallInst *> CallersOf(llvm::Function *func);
248249
std::string ModuleName(llvm::Module *module);
249250
std::string ModuleName(const std::unique_ptr<llvm::Module> &module);
250251

252+
// Replace all uses of a constant `old_c` with `new_c` inside of `module`.
253+
//
254+
// Returns the number of constant uses of `old_c`.
255+
unsigned ReplaceAllUsesOfConstant(llvm::Constant *old_c,
256+
llvm::Constant *new_c,
257+
llvm::Module *module);
258+
251259
// Move a function from one module into another module.
252260
void MoveFunctionIntoModule(llvm::Function *func, llvm::Module *dest_module);
253261

lib/BC/Util.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,9 +1477,9 @@ void CloneFunctionInto(llvm::Function *source_func, llvm::Function *dest_func,
14771477
// Replace all uses of a constant `old_c` with `new_c` inside of `module`.
14781478
//
14791479
// Returns the number of constant uses of `old_c`.
1480-
static unsigned ReplaceAllUsesOfConstant(llvm::Constant *old_c,
1481-
llvm::Constant *new_c,
1482-
llvm::Module *module) {
1480+
unsigned ReplaceAllUsesOfConstant(llvm::Constant *old_c,
1481+
llvm::Constant *new_c,
1482+
llvm::Module *module) {
14831483
std::vector<llvm::Use *> repls;
14841484
for (auto &use : old_c->uses()) {
14851485
repls.emplace_back(&use);

0 commit comments

Comments
 (0)