#include "llvm/Transforms/IPO/BlockExtractor.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/CodeExtractor.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumExtracted, "Number of basic blocks extracted");
static cl::opt<std::string> BlockExtractorFile(
"extract-blocks-file", cl::value_desc("filename"),
cl::desc("A file containing list of basic blocks to extract"), cl::Hidden);
static cl::opt<bool>
BlockExtractorEraseFuncs("extract-blocks-erase-funcs",
cl::desc("Erase the existing functions"),
cl::Hidden);
namespace {
class BlockExtractor { … };
}
void BlockExtractor::loadFile() { … }
void BlockExtractor::splitLandingPadPreds(Function &F) { … }
bool BlockExtractor::runOnModule(Module &M) { … }
BlockExtractorPass::BlockExtractorPass(
std::vector<std::vector<BasicBlock *>> &&GroupsOfBlocks,
bool EraseFunctions)
: … { … }
PreservedAnalyses BlockExtractorPass::run(Module &M,
ModuleAnalysisManager &AM) { … }