Skip to content

Commit

Permalink
Add requires/preserves/establishes for HasSourceBlocks checker
Browse files Browse the repository at this point in the history
Summary:
InsertSourceBlocksPass establishes it.
Passes which may use profile info require it.
InstrumentPass destroys/does not preserve it.

Reviewed By: agampe

Differential Revision: D44941800

fbshipit-source-id: 076c65324b627857f883b56ca825884f3e6627cd
  • Loading branch information
Jimmy Cleary authored and facebook-github-bot committed Apr 14, 2023
1 parent c0f74b2 commit 88ac642
Show file tree
Hide file tree
Showing 103 changed files with 645 additions and 9 deletions.
7 changes: 7 additions & 0 deletions analysis/ip-reflection-analysis/IPReflectionAnalysis.h
Expand Up @@ -15,6 +15,13 @@ class IPReflectionAnalysisPass : public Pass {
public:
IPReflectionAnalysisPass()
: Pass("IPReflectionAnalysisPass", Pass::ANALYSIS) {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override {
bind("max_iteration", 20U, m_max_iteration);
bind("export_results", false, m_export_results,
Expand Down
7 changes: 7 additions & 0 deletions analysis/max-depth/MaxDepthAnalysis.h
Expand Up @@ -15,6 +15,13 @@
class MaxDepthAnalysisPass : public Pass {
public:
MaxDepthAnalysisPass() : Pass("MaxDepthAnalysisPass", Pass::ANALYSIS) {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override { bind("max_iteration", 20U, m_max_iteration); }
void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;

Expand Down
6 changes: 6 additions & 0 deletions opt/access-marking/AccessMarking.h
Expand Up @@ -13,6 +13,12 @@ class AccessMarkingPass : public Pass {
public:
AccessMarkingPass() : Pass("AccessMarkingPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

std::string get_config_doc() override {
return "This pass will mark class, methods, and fields final, when able to "
"do so. This is generally advantageous for performance. It will "
Expand Down
6 changes: 6 additions & 0 deletions opt/analyze-pure-method/PureMethods.h
Expand Up @@ -30,6 +30,12 @@ class AnalyzePureMethodsPass : public Pass {

AnalyzePureMethodsPass() : Pass("AnalyzePureMethodsPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;

bool is_editable_cfg_friendly() override { return true; }
Expand Down
7 changes: 7 additions & 0 deletions opt/annokill/AnnoKill.h
Expand Up @@ -115,6 +115,13 @@ class AnnoKill {
class AnnoKillPass : public Pass {
public:
AnnoKillPass() : Pass("AnnoKillPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

explicit AnnoKillPass(const std::string& name) : Pass(name) {}

void bind_config() override {
Expand Down
6 changes: 6 additions & 0 deletions opt/app_module_usage/AppModuleUsage.h
Expand Up @@ -45,6 +45,12 @@ class AppModuleUsagePass : public Pass {
public:
AppModuleUsagePass() : Pass("AppModuleUsagePass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override {
bind("uses_app_module_annotation_descriptor",
DexType::get_type("Lcom/facebook/redex/annotations/UsesAppModule;"),
Expand Down
6 changes: 6 additions & 0 deletions opt/basic-block/BasicBlockProfile.h
Expand Up @@ -13,5 +13,11 @@ class BasicBlockProfilePass : public Pass {
public:
BasicBlockProfilePass() : Pass("BasicBlockProfilePass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;
};
5 changes: 4 additions & 1 deletion opt/branch-prefix-hoisting/BranchPrefixHoisting.h
Expand Up @@ -30,7 +30,10 @@ class BranchPrefixHoistingPass : public Pass {
redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{NoInitClassInstructions, {.preserves = true}}};
return {
{NoInitClassInstructions, {.preserves = true}},
{HasSourceBlocks, {.preserves = true}},
};
}

void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;
Expand Down
7 changes: 7 additions & 0 deletions opt/builder_pattern/RemoveBuilderPattern.h
Expand Up @@ -16,6 +16,13 @@ namespace builder_pattern {
class RemoveBuilderPatternPass : public Pass {
public:
RemoveBuilderPatternPass() : Pass("RemoveBuilderPatternPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

explicit RemoveBuilderPatternPass(const std::string& name) : Pass(name) {}

void bind_config() override;
Expand Down
6 changes: 6 additions & 0 deletions opt/check-recursion/CheckRecursion.h
Expand Up @@ -13,6 +13,12 @@ class CheckRecursionPass : public Pass {
public:
CheckRecursionPass() : Pass("CheckRecursionPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

int bad_recursion_count{4};

void bind_config() override {
Expand Down
5 changes: 4 additions & 1 deletion opt/check_breadcrumbs/CheckBreadcrumbs.h
Expand Up @@ -30,7 +30,10 @@ class CheckBreadcrumbsPass : public Pass {
redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{NoInitClassInstructions, {.preserves = true}}};
return {
{NoInitClassInstructions, {.preserves = true}},
{HasSourceBlocks, {.preserves = true}},
};
}

void bind_config() override {
Expand Down
6 changes: 6 additions & 0 deletions opt/class-merging/AnonymousClassMergingPass.h
Expand Up @@ -17,6 +17,12 @@ class AnonymousClassMergingPass : public Pass {
public:
AnonymousClassMergingPass() : Pass("AnonymousClassMergingPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override;
void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;

Expand Down
7 changes: 7 additions & 0 deletions opt/class-merging/ClassMergingPass.h
Expand Up @@ -21,6 +21,13 @@ class ModelMerger;
class ClassMergingPass : public Pass {
public:
ClassMergingPass() : Pass("ClassMergingPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

explicit ClassMergingPass(const char* name) : Pass(name) {}

void bind_config() override;
Expand Down
6 changes: 6 additions & 0 deletions opt/class-merging/IntraDexClassMergingPass.h
Expand Up @@ -24,6 +24,12 @@ class IntraDexClassMergingPass : public Pass {
public:
IntraDexClassMergingPass() : Pass("IntraDexClassMergingPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override;
void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;

Expand Down
6 changes: 6 additions & 0 deletions opt/class-splitting/ClassSplittingPass.h
Expand Up @@ -16,6 +16,12 @@ class ClassSplittingPass : public Pass {
public:
ClassSplittingPass() : Pass("ClassSplittingPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.requires_ = true, .preserves = true}}};
}

void bind_config() override {
bind("enabled", m_config.enabled, m_config.enabled);
bind("combine_target_classes_by_api_level",
Expand Down
6 changes: 6 additions & 0 deletions opt/constant-propagation/ConstantPropagationPass.h
Expand Up @@ -16,6 +16,12 @@ class ConstantPropagationPass : public Pass {
public:
ConstantPropagationPass() : Pass("ConstantPropagationPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override {
bind("replace_moves_with_consts",
true,
Expand Down
6 changes: 6 additions & 0 deletions opt/constant-propagation/IPConstantPropagation.h
Expand Up @@ -41,6 +41,12 @@ class PassImpl : public Pass {
: Pass("InterproceduralConstantPropagationPass"),
m_config(std::move(config)) {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

PassImpl() : PassImpl(Config()) {}

void bind_config() override {
Expand Down
5 changes: 4 additions & 1 deletion opt/copy-propagation/CopyPropagationPass.h
Expand Up @@ -17,7 +17,10 @@ class CopyPropagationPass : public Pass {
redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{NoInitClassInstructions, {.preserves = true}}};
return {
{NoInitClassInstructions, {.preserves = true}},
{HasSourceBlocks, {.preserves = true}},
};
}

void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;
Expand Down
6 changes: 6 additions & 0 deletions opt/cse/CommonSubexpressionEliminationPass.h
Expand Up @@ -15,6 +15,12 @@ class CommonSubexpressionEliminationPass : public Pass {
CommonSubexpressionEliminationPass()
: Pass("CommonSubexpressionEliminationPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override;
void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;

Expand Down
6 changes: 6 additions & 0 deletions opt/dedup-strings/DedupStrings.h
Expand Up @@ -172,6 +172,12 @@ class DedupStringsPass : public Pass {
public:
DedupStringsPass() : Pass("DedupStringsPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.requires_ = true, .preserves = true}}};
}

void bind_config() override;
void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;
bool is_editable_cfg_friendly() override { return true; }
Expand Down
5 changes: 4 additions & 1 deletion opt/dedup_blocks/DedupBlocksPass.h
Expand Up @@ -17,7 +17,10 @@ class DedupBlocksPass : public Pass {
redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{NoInitClassInstructions, {.preserves = true}}};
return {
{NoInitClassInstructions, {.preserves = true}},
{HasSourceBlocks, {.preserves = true}},
};
}

void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;
Expand Down
6 changes: 6 additions & 0 deletions opt/dedup_resources/DedupResources.h
Expand Up @@ -51,6 +51,12 @@ class DedupResourcesPass : public Pass {
public:
DedupResourcesPass() : Pass("DedupResourcesPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override {
bind("disallowed_types", {}, m_disallowed_types);
bind("disallowed_resources", {}, m_disallowed_resources);
Expand Down
6 changes: 6 additions & 0 deletions opt/delinit/DelInit.h
Expand Up @@ -13,6 +13,12 @@ class DelInitPass : public Pass {
public:
DelInitPass() : Pass("DelInitPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override {
bind("package_allowlist", {}, m_package_filter);
}
Expand Down
6 changes: 6 additions & 0 deletions opt/delsuper/DelSuper.h
Expand Up @@ -14,5 +14,11 @@ class DelSuperPass : public Pass {
public:
DelSuperPass() : Pass("DelSuperPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;
};
6 changes: 6 additions & 0 deletions opt/evaluate_type_checks/EvaluateTypeChecks.h
Expand Up @@ -22,6 +22,12 @@ class EvaluateTypeChecksPass : public Pass {
public:
EvaluateTypeChecksPass() : Pass("EvaluateTypeChecksPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;

// Exposed for testing.
Expand Down
6 changes: 6 additions & 0 deletions opt/final_inline/FinalInline.h
Expand Up @@ -27,6 +27,12 @@ class FinalInlinePass : public Pass {
public:
FinalInlinePass() : Pass("FinalInlinePass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override {
bind("blocklist_annos",
{},
Expand Down
6 changes: 6 additions & 0 deletions opt/final_inline/FinalInlineV2.h
Expand Up @@ -27,6 +27,12 @@ class FinalInlinePassV2 : public Pass {

FinalInlinePassV2() : Pass("FinalInlinePassV2") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.preserves = true}}};
}

void bind_config() override {
bind("inline_instance_field", true, m_config.inline_instance_field);
bind("blocklist_types",
Expand Down
5 changes: 4 additions & 1 deletion opt/init-classes/InitClassLoweringPass.h
Expand Up @@ -17,7 +17,10 @@ class InitClassLoweringPass : public Pass {
redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{NoInitClassInstructions, {.establishes = true}}};
return {
{NoInitClassInstructions, {.establishes = true}},
{HasSourceBlocks, {.preserves = true}},
};
}

void bind_config() override;
Expand Down
6 changes: 6 additions & 0 deletions opt/insert-source-blocks/InsertSourceBlocks.h
Expand Up @@ -22,6 +22,12 @@ class InsertSourceBlocksPass : public Pass {
public:
InsertSourceBlocksPass() : Pass("InsertSourceBlocksPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.establishes = true}}};
}

void bind_config() override;
void run_pass(DexStoresVector&, ConfigFiles&, PassManager&) override;

Expand Down
6 changes: 6 additions & 0 deletions opt/instrument/Instrument.h
Expand Up @@ -31,6 +31,12 @@ class InstrumentPass : public Pass {
public:
InstrumentPass() : Pass("InstrumentPass") {}

redex_properties::PropertyInteractions get_property_interactions()
const override {
using namespace redex_properties::names;
return {{HasSourceBlocks, {.requires_ = true, .preserves = false}}};
}

void bind_config() override;
void eval_pass(DexStoresVector& stores,
ConfigFiles& conf,
Expand Down

0 comments on commit 88ac642

Please sign in to comment.