mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
Clarify the logic: the flag is renamed to `deleteFn' to signify it will delete
the function instead of isolating it. This also means the condition is reversed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13112 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -66,11 +66,11 @@ Pass *createGlobalDCEPass();
|
|||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// createFunctionExtractionPass - If isolateFn is true, this pass deletes as
|
/// createFunctionExtractionPass - If deleteFn is true, this pass deletes as
|
||||||
/// much of the module as possible, except for the function specified.
|
/// the specified function. Otherwise, it deletes as much of the module as
|
||||||
/// Otherwise, it deletes the given function, leaving everything else intact.
|
/// possible, except for the function specified.
|
||||||
///
|
///
|
||||||
Pass *createFunctionExtractionPass(Function *F, bool isolateFn = true);
|
Pass *createFunctionExtractionPass(Function *F, bool deleteFn = false);
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -19,14 +19,14 @@ using namespace llvm;
|
|||||||
namespace {
|
namespace {
|
||||||
class FunctionExtractorPass : public Pass {
|
class FunctionExtractorPass : public Pass {
|
||||||
Function *Named;
|
Function *Named;
|
||||||
bool isolateFunc;
|
bool deleteFunc;
|
||||||
public:
|
public:
|
||||||
/// FunctionExtractorPass - ctor for the pass. If isolateFn is true, then
|
/// FunctionExtractorPass - If deleteFn is true, this pass deletes as the
|
||||||
/// the named function is the only thing left in the Module (default
|
/// specified function. Otherwise, it deletes as much of the module as
|
||||||
/// behavior), otherwise the function is the thing deleted.
|
/// possible, except for the function specified.
|
||||||
///
|
///
|
||||||
FunctionExtractorPass(Function *F = 0, bool isolateFn = true)
|
FunctionExtractorPass(Function *F = 0, bool deleteFn = true)
|
||||||
: Named(F), isolateFunc(isolateFn) {}
|
: Named(F), deleteFunc(deleteFn) {}
|
||||||
|
|
||||||
bool run(Module &M) {
|
bool run(Module &M) {
|
||||||
if (Named == 0) {
|
if (Named == 0) {
|
||||||
@ -34,10 +34,10 @@ namespace {
|
|||||||
if (Named == 0) return false; // No function to extract
|
if (Named == 0) return false; // No function to extract
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isolateFunc)
|
if (deleteFunc)
|
||||||
return isolateFunction(M);
|
|
||||||
else
|
|
||||||
return deleteFunction();
|
return deleteFunction();
|
||||||
|
else
|
||||||
|
return isolateFunction(M);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deleteFunction() {
|
bool deleteFunction() {
|
||||||
@ -112,6 +112,6 @@ namespace {
|
|||||||
RegisterPass<FunctionExtractorPass> X("extract", "Function Extractor");
|
RegisterPass<FunctionExtractorPass> X("extract", "Function Extractor");
|
||||||
}
|
}
|
||||||
|
|
||||||
Pass *llvm::createFunctionExtractionPass(Function *F, bool isolateFn) {
|
Pass *llvm::createFunctionExtractionPass(Function *F, bool deleteFn) {
|
||||||
return new FunctionExtractorPass(F, isolateFn);
|
return new FunctionExtractorPass(F, deleteFn);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user