[ExecutionEngine] Remove unused functions
authorKazu Hirata <kazu@google.com>
Tue, 13 Jun 2023 07:24:38 +0000 (00:24 -0700)
committerKazu Hirata <kazu@google.com>
Tue, 13 Jun 2023 07:24:38 +0000 (00:24 -0700)
This patch removes:

  cloneModuleFlagsMetadata
  moveFunctionBody
  moveGlobalVariableInitializer

Their last uses were removed by:

  commit 6154c4115cd4b78d0171892aac21e340e72e32bd
  Author: Lang Hames <lhames@gmail.com>
  Date:   Mon Sep 7 21:21:28 2020 -0700

Differential Revision: https://reviews.llvm.org/D152668

llvm/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
llvm/lib/ExecutionEngine/Orc/IndirectionUtils.cpp

index 71ece42..3b9ba55 100644 (file)
@@ -513,7 +513,7 @@ private:
 /// Clone a function declaration into a new module.
 ///
 ///   This function can be used as the first step towards creating a callback
-/// stub (see makeStub), or moving a function body (see moveFunctionBody).
+/// stub (see makeStub).
 ///
 ///   If the VMap argument is non-null, a mapping will be added between F and
 /// the new declaration, and between each of F's arguments and the new
@@ -525,43 +525,14 @@ private:
 Function *cloneFunctionDecl(Module &Dst, const Function &F,
                             ValueToValueMapTy *VMap = nullptr);
 
-/// Move the body of function 'F' to a cloned function declaration in a
-///        different module (See related cloneFunctionDecl).
-///
-///   If the target function declaration is not supplied via the NewF parameter
-/// then it will be looked up via the VMap.
-///
-///   This will delete the body of function 'F' from its original parent module,
-/// but leave its declaration.
-void moveFunctionBody(Function &OrigF, ValueToValueMapTy &VMap,
-                      ValueMaterializer *Materializer = nullptr,
-                      Function *NewF = nullptr);
-
 /// Clone a global variable declaration into a new module.
 GlobalVariable *cloneGlobalVariableDecl(Module &Dst, const GlobalVariable &GV,
                                         ValueToValueMapTy *VMap = nullptr);
 
-/// Move global variable GV from its parent module to cloned global
-///        declaration in a different module.
-///
-///   If the target global declaration is not supplied via the NewGV parameter
-/// then it will be looked up via the VMap.
-///
-///   This will delete the initializer of GV from its original parent module,
-/// but leave its declaration.
-void moveGlobalVariableInitializer(GlobalVariable &OrigGV,
-                                   ValueToValueMapTy &VMap,
-                                   ValueMaterializer *Materializer = nullptr,
-                                   GlobalVariable *NewGV = nullptr);
-
 /// Clone a global alias declaration into a new module.
 GlobalAlias *cloneGlobalAliasDecl(Module &Dst, const GlobalAlias &OrigA,
                                   ValueToValueMapTy &VMap);
 
-/// Clone module flags metadata into the destination module.
-void cloneModuleFlagsMetadata(Module &Dst, const Module &Src,
-                              ValueToValueMapTy &VMap);
-
 /// Introduce relocations to \p Sym in its own definition if there are any
 /// pointers formed via PC-relative address that do not already have a
 /// relocation.
index 8f2537d..a0d81cd 100644 (file)
@@ -325,26 +325,6 @@ Function* cloneFunctionDecl(Module &Dst, const Function &F,
   return NewF;
 }
 
-void moveFunctionBody(Function &OrigF, ValueToValueMapTy &VMap,
-                      ValueMaterializer *Materializer,
-                      Function *NewF) {
-  assert(!OrigF.isDeclaration() && "Nothing to move");
-  if (!NewF)
-    NewF = cast<Function>(VMap[&OrigF]);
-  else
-    assert(VMap[&OrigF] == NewF && "Incorrect function mapping in VMap.");
-  assert(NewF && "Function mapping missing from VMap.");
-  assert(NewF->getParent() != OrigF.getParent() &&
-         "moveFunctionBody should only be used to move bodies between "
-         "modules.");
-
-  SmallVector<ReturnInst *, 8> Returns; // Ignore returns cloned.
-  CloneFunctionInto(NewF, &OrigF, VMap,
-                    CloneFunctionChangeType::DifferentModule, Returns, "",
-                    nullptr, nullptr, Materializer);
-  OrigF.deleteBody();
-}
-
 GlobalVariable* cloneGlobalVariableDecl(Module &Dst, const GlobalVariable &GV,
                                         ValueToValueMapTy *VMap) {
   GlobalVariable *NewGV = new GlobalVariable(
@@ -357,24 +337,6 @@ GlobalVariable* cloneGlobalVariableDecl(Module &Dst, const GlobalVariable &GV,
   return NewGV;
 }
 
-void moveGlobalVariableInitializer(GlobalVariable &OrigGV,
-                                   ValueToValueMapTy &VMap,
-                                   ValueMaterializer *Materializer,
-                                   GlobalVariable *NewGV) {
-  assert(OrigGV.hasInitializer() && "Nothing to move");
-  if (!NewGV)
-    NewGV = cast<GlobalVariable>(VMap[&OrigGV]);
-  else
-    assert(VMap[&OrigGV] == NewGV &&
-           "Incorrect global variable mapping in VMap.");
-  assert(NewGV->getParent() != OrigGV.getParent() &&
-         "moveGlobalVariableInitializer should only be used to move "
-         "initializers between modules");
-
-  NewGV->setInitializer(MapValue(OrigGV.getInitializer(), VMap, RF_None,
-                                 nullptr, Materializer));
-}
-
 GlobalAlias* cloneGlobalAliasDecl(Module &Dst, const GlobalAlias &OrigA,
                                   ValueToValueMapTy &VMap) {
   assert(OrigA.getAliasee() && "Original alias doesn't have an aliasee?");
@@ -386,15 +348,6 @@ GlobalAlias* cloneGlobalAliasDecl(Module &Dst, const GlobalAlias &OrigA,
   return NewA;
 }
 
-void cloneModuleFlagsMetadata(Module &Dst, const Module &Src,
-                              ValueToValueMapTy &VMap) {
-  auto *MFs = Src.getModuleFlagsMetadata();
-  if (!MFs)
-    return;
-  for (auto *MF : MFs->operands())
-    Dst.addModuleFlag(MapMetadata(MF, VMap));
-}
-
 Error addFunctionPointerRelocationsToCurrentSymbol(jitlink::Symbol &Sym,
                                                    jitlink::LinkGraph &G,
                                                    MCDisassembler &Disassembler,