Merge pull request #653 from Sonicadvance1/add_O0

Adds an option to disable optimization passes
This commit is contained in:
Ryan Houdek 2021-01-18 00:10:48 -08:00 committed by GitHub
commit 108992de80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 13 deletions

View File

@ -2,28 +2,39 @@
#include "Interface/IR/Passes/RegisterAllocationPass.h"
#include "Interface/IR/PassManager.h"
#include <FEXCore/Config/Config.h>
namespace FEXCore::IR {
void PassManager::AddDefaultPasses(bool InlineConstants, bool StaticRegisterAllocation) {
InsertPass(CreateContextLoadStoreElimination());
InsertPass(CreateDeadFlagStoreElimination());
InsertPass(CreateDeadGPRStoreElimination());
InsertPass(CreateDeadFPRStoreElimination());
InsertPass(CreatePassDeadCodeElimination());
InsertPass(CreateConstProp(InlineConstants));
FEXCore::Config::Value<bool> DisablePasses{FEXCore::Config::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, false};
////// InsertPass(CreateDeadFlagCalculationEliminination());
if (!DisablePasses()) {
InsertPass(CreateContextLoadStoreElimination());
InsertPass(CreateDeadFlagStoreElimination());
InsertPass(CreateDeadGPRStoreElimination());
InsertPass(CreateDeadFPRStoreElimination());
InsertPass(CreatePassDeadCodeElimination());
InsertPass(CreateConstProp(InlineConstants));
InsertPass(CreateSyscallOptimization());
InsertPass(CreatePassDeadCodeElimination());
////// InsertPass(CreateDeadFlagCalculationEliminination());
// only do SRA if enabled and JIT
if (InlineConstants && StaticRegisterAllocation)
InsertPass(CreateStaticRegisterAllocationPass());
InsertPass(CreateSyscallOptimization());
InsertPass(CreatePassDeadCodeElimination());
// only do SRA if enabled and JIT
if (InlineConstants && StaticRegisterAllocation)
InsertPass(CreateStaticRegisterAllocationPass());
}
else {
// only do SRA if enabled and JIT
if (InlineConstants && StaticRegisterAllocation)
InsertPass(CreateStaticRegisterAllocationPass());
}
CompactionPass = CreateIRCompaction();
// If the IR is compacted post-RA then the node indexing gets messed up and the backend isn't able to find the register assigned to a node
// Compact before IR, don't worry about RA generating spills/fills
CompactionPass = CreateIRCompaction();
InsertPass(CompactionPass);
}

View File

@ -30,6 +30,7 @@ namespace FEXCore::Config {
CONFIG_IS_INTERPRETER,
CONFIG_INTERPRETER_INSTALLED,
CONFIG_APP_FILENAME,
CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES,
};
enum ConfigCore {

View File

@ -109,6 +109,11 @@ namespace FEX::ArgLoader {
.help("Adds an environment variable")
.action("append");
EmulationGroup.add_option("-O")
.dest("O0")
.help("Disables optimization passes for debugging")
.choices({"0"});
Parser.add_option_group(EmulationGroup);
}
{
@ -241,6 +246,9 @@ namespace FEX::ArgLoader {
Set(FEXCore::Config::ConfigOption::CONFIG_ENVIRONMENT, *iter);
}
}
if (Options.is_set_by_user("O0")) {
Set(FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, std::to_string(true));
}
}
{

View File

@ -186,6 +186,7 @@ namespace FEX::Config {
{FEXCore::Config::ConfigOption::CONFIG_SMC_CHECKS, "SMCChecks"},
{FEXCore::Config::ConfigOption::CONFIG_ABI_LOCAL_FLAGS, "ABILocalFlags"},
{FEXCore::Config::ConfigOption::CONFIG_ABI_NO_PF, "ABINoPF"},
{FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, "O0"},
}};
@ -232,6 +233,7 @@ namespace FEX::Config {
{"SMCChecks", FEXCore::Config::ConfigOption::CONFIG_SMC_CHECKS},
{"ABILocalFlags", FEXCore::Config::ConfigOption::CONFIG_ABI_LOCAL_FLAGS},
{"AbiNoPF", FEXCore::Config::ConfigOption::CONFIG_ABI_NO_PF},
{"O0", FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES},
}};
void OptionMapper::MapNameToOption(const char *ConfigName, const char *ConfigString) {

View File

@ -74,6 +74,7 @@ namespace {
LoadedConfig->Set(FEXCore::Config::ConfigOption::CONFIG_SMC_CHECKS, "0");
LoadedConfig->Set(FEXCore::Config::ConfigOption::CONFIG_ABI_LOCAL_FLAGS, "0");
LoadedConfig->Set(FEXCore::Config::ConfigOption::CONFIG_ABI_NO_PF, "0");
LoadedConfig->Set(FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, "0");
}
void SaveFile(std::string Filename) {
@ -245,6 +246,14 @@ namespace {
}
}
ImGui::Text("Debugging:");
Value = LoadedConfig->Get(FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES);
bool DisablePasses = Value.has_value() && **Value == "1";
if (ImGui::Checkbox("Disable Optimization Passes", &DisablePasses)) {
LoadedConfig->EraseSet(FEXCore::Config::ConfigOption::CONFIG_DEBUG_DISABLE_OPTIMIZATION_PASSES, DisablePasses ? "1" : "0");
ConfigChanged = true;
}
ImGui::EndTabItem();
}
}