//===-- ExtractGV.cpp - Global Value extraction pass ----------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This pass extracts global values // //===----------------------------------------------------------------------===// #include "llvm/Transforms/IPO/ExtractGV.h" #include "llvm/IR/Module.h" #include "llvm/IR/PassManager.h" #include <algorithm> usingnamespacellvm; /// Make sure GV is visible from both modules. Delete is true if it is /// being deleted from this module. /// This also makes sure GV cannot be dropped so that references from /// the split module remain valid. static void makeVisible(GlobalValue &GV, bool Delete) { … } /// If deleteS is true, this pass deletes the specified global values. /// Otherwise, it deletes as much of the module as possible, except for the /// global values specified. ExtractGVPass::ExtractGVPass(std::vector<GlobalValue *> &GVs, bool deleteS, bool keepConstInit) : … { … } PreservedAnalyses ExtractGVPass::run(Module &M, ModuleAnalysisManager &) { … }