Added debug option to print-after specific passes (#4196)
This commit is contained in:
Родитель
19139d829d
Коммит
13553274a8
|
@ -221,6 +221,7 @@ public:
|
|||
std::map<std::string, std::string> OverrideSemDefs; // OPT_override_semdef
|
||||
|
||||
bool PrintAfterAll; // OPT_print_after_all
|
||||
std::set<std::string> PrintAfter; // OPT_print_after
|
||||
bool EnablePayloadQualifiers = false; // OPT_enable_payload_qualifiers
|
||||
bool HandleExceptions = false; // OPT_disable_exception_handling
|
||||
|
||||
|
|
|
@ -284,6 +284,8 @@ def validator_version : Separate<["-", "/"], "validator-version">, Group<hlslcom
|
|||
HelpText<"Override validator version for module. Format: <major.minor> ; Default: DXIL.dll version or current internal version.">;
|
||||
def print_after_all : Flag<["-", "/"], "print-after-all">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
|
||||
HelpText<"Print LLVM IR after each pass.">;
|
||||
def print_after : Separate<["-", "/"], "print-after">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
|
||||
HelpText<"Print LLVM IR after a specific pass.">;
|
||||
def ignore_opt_semdefs : Flag<["-", "/"], "ignore-opt-semdefs">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
|
||||
HelpText<"Ignore optional semantic defines which are not required to ensure program correctness.">;
|
||||
def ignore_semdef : Separate<["-", "/"], "ignore-semdef">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/CBindingWrapping.h"
|
||||
#include <set> // HLSL change
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -36,6 +37,7 @@ class FunctionPassManagerImpl;
|
|||
class PassManagerBase {
|
||||
public:
|
||||
bool HLSLPrintAfterAll = false; // HLSL Change
|
||||
std::set<std::string> HLSLPrintAfter; // HLSL Change
|
||||
|
||||
virtual ~PassManagerBase();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "llvm/Pass.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <set> // HLSL change
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Overview:
|
||||
|
@ -180,6 +181,7 @@ private:
|
|||
|
||||
public:
|
||||
bool HLSLPrintAfterAll = false; // HLSL Change
|
||||
std::set<std::string> HLSLPrintAfter; // HLSL Change
|
||||
|
||||
/// Schedule pass P for execution. Make sure that passes required by
|
||||
/// P are run before P is run. Update analysis info maintained by
|
||||
|
|
|
@ -762,6 +762,10 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
|
|||
opts.EnablePayloadQualifiers = Args.hasFlag(OPT_enable_payload_qualifiers, OPT_INVALID,
|
||||
DXIL::CompareVersions(Major, Minor, 6, 7) >= 0);
|
||||
|
||||
for (const std::string &value : Args.getAllArgValues(OPT_print_after)) {
|
||||
opts.PrintAfter.insert(value);
|
||||
}
|
||||
|
||||
if (DXIL::CompareVersions(Major, Minor, 6, 8) < 0) {
|
||||
opts.EnablePayloadQualifiers &= !Args.hasFlag(OPT_disable_payload_qualifiers, OPT_INVALID, false);
|
||||
}
|
||||
|
|
|
@ -695,7 +695,7 @@ void PMTopLevelManager::schedulePass(Pass *P) {
|
|||
}
|
||||
|
||||
// HLSL Change - begin
|
||||
if (PI && !PI->isAnalysis() && this->HLSLPrintAfterAll) {
|
||||
if (PI && !PI->isAnalysis() && (this->HLSLPrintAfterAll || (this->HLSLPrintAfter.size() && this->HLSLPrintAfter.count(PI->getPassArgument())))) {
|
||||
class direct_stderr_stream : public raw_ostream {
|
||||
uint64_t current_pos() const override { return 0; }
|
||||
/// See raw_ostream::write_impl.
|
||||
|
@ -1420,6 +1420,7 @@ FunctionPassManager::~FunctionPassManager() {
|
|||
void FunctionPassManager::add(Pass *P) {
|
||||
// HLSL Change Starts
|
||||
FPM->HLSLPrintAfterAll = this->HLSLPrintAfterAll;
|
||||
FPM->HLSLPrintAfter = this->HLSLPrintAfter;
|
||||
std::unique_ptr<Pass> PPtr(P); // take ownership of P, even on failure paths
|
||||
if (TrackPassOS) {
|
||||
P->dumpConfig(*TrackPassOS);
|
||||
|
@ -1769,6 +1770,7 @@ PassManager::~PassManager() {
|
|||
void PassManager::add(Pass *P) {
|
||||
// HLSL Change Starts
|
||||
PM->HLSLPrintAfterAll = this->HLSLPrintAfterAll;
|
||||
PM->HLSLPrintAfter = this->HLSLPrintAfter;
|
||||
std::unique_ptr<Pass> PPtr(P); // take ownership of P, even on failure paths
|
||||
if (TrackPassOS) {
|
||||
P->dumpConfig(*TrackPassOS);
|
||||
|
|
|
@ -236,6 +236,8 @@ public:
|
|||
std::map<std::string, std::string> HLSLOptimizationSelects;
|
||||
/// Debug option to print IR after every pass
|
||||
bool HLSLPrintAfterAll = false;
|
||||
/// Debug option to print IR after specific pass
|
||||
std::set<std::string> HLSLPrintAfter;
|
||||
/// Force-replace lifetime intrinsics by zeroinitializer stores.
|
||||
bool HLSLForceZeroStoreLifetimes = false;
|
||||
/// Enable lifetime marker generation
|
||||
|
|
|
@ -92,6 +92,7 @@ private:
|
|||
if (!PerModulePasses) {
|
||||
PerModulePasses = new legacy::PassManager();
|
||||
PerModulePasses->HLSLPrintAfterAll = this->CodeGenOpts.HLSLPrintAfterAll;
|
||||
PerModulePasses->HLSLPrintAfter = this->CodeGenOpts.HLSLPrintAfter;
|
||||
PerModulePasses->TrackPassOS = &PerModulePassesConfigOS;
|
||||
PerModulePasses->add(
|
||||
createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
|
||||
|
@ -103,6 +104,7 @@ private:
|
|||
if (!PerFunctionPasses) {
|
||||
PerFunctionPasses = new legacy::FunctionPassManager(TheModule);
|
||||
PerFunctionPasses->HLSLPrintAfterAll = this->CodeGenOpts.HLSLPrintAfterAll;
|
||||
PerFunctionPasses->HLSLPrintAfter = this->CodeGenOpts.HLSLPrintAfter;
|
||||
PerFunctionPasses->TrackPassOS = &PerFunctionPassesConfigOS;
|
||||
PerFunctionPasses->add(
|
||||
createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
|
||||
|
|
|
@ -1469,6 +1469,7 @@ public:
|
|||
compiler.getCodeGenOpts().HLSLPreciseOutputs = Opts.PreciseOutputs;
|
||||
compiler.getCodeGenOpts().MainFileName = pMainFile;
|
||||
compiler.getCodeGenOpts().HLSLPrintAfterAll = Opts.PrintAfterAll;
|
||||
compiler.getCodeGenOpts().HLSLPrintAfter = Opts.PrintAfter;
|
||||
compiler.getCodeGenOpts().HLSLForceZeroStoreLifetimes = Opts.ForceZeroStoreLifetimes;
|
||||
compiler.getCodeGenOpts().HLSLEnableLifetimeMarkers = Opts.EnableLifetimeMarkers;
|
||||
compiler.getCodeGenOpts().HLSLEnablePayloadAccessQualifiers = Opts.EnablePayloadQualifiers;
|
||||
|
|
Загрузка…
Ссылка в новой задаче