Add option to force disabling debug info (#4645)

This is (admittedly) a little hacky. DXC spends a lot of compile time
updating debug information because we always generate it so that we can
generate diagnostics for late-running validation.

This patch adds a new flag -fdisable-loc-tracking, which disables
generating debug locations if the user is not generating debug info.

This flag results in about a 15% compile time improvement on a pessimistic
test case. YMMV.
This commit is contained in:
Chris B 2022-09-16 16:36:16 -05:00 коммит произвёл GitHub
Родитель 42eb79311e
Коммит b49ecd10ee
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 40 добавлений и 1 удалений

Просмотреть файл

@ -205,6 +205,7 @@ public:
unsigned ScanLimit = 0; // OPT_memdep_block_scan_limit
bool ForceZeroStoreLifetimes = false; // OPT_force_zero_store_lifetimes
bool EnableLifetimeMarkers = false; // OPT_enable_lifetime_markers
bool ForceDisableLocTracking = false; // OPT_fdisable_loc_tracking
bool EnableTemplates = false; // OPT_enable_templates
bool EnableOperatorOverloading = false; // OPT_enable_operator_overloading
bool StrictUDTCasting = false; // OPT_strict_udt_casting

Просмотреть файл

@ -168,6 +168,10 @@ def opt_enable : Separate<["-", "/"], "opt-enable">, Group<hlsloptz_Group>, Flag
def opt_select : MultiArg<["-", "/"], "opt-select", 2>, MetaVarName<"<opt> <variant>">, Group<hlsloptz_Group>, Flags<[CoreOption, DriverOption, HelpHidden]>,
HelpText<"Select this optimization variant.">;
def fdisable_loc_tracking : Flag<["-"], "fdisable-loc-tracking">,
Group<hlslcomp_Group>, Flags<[CoreOption]>,
HelpText<"Disable source location tracking in IR. This will break diagnostic generation for late validation. (Ignored if /Zi is passed)">;
/*
def fno_caret_diagnostics : Flag<["-"], "fno-caret-diagnostics">, Group<hlslcomp_Group>,
Flags<[CoreOption]>;

Просмотреть файл

@ -828,6 +828,8 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
opts.EnableLifetimeMarkers = Args.hasFlag(OPT_enable_lifetime_markers, OPT_INVALID,
DXIL::CompareVersions(Major, Minor, 6, 6) >= 0) &&
!Args.hasFlag(OPT_disable_lifetime_markers, OPT_INVALID, false);
opts.ForceDisableLocTracking =
Args.hasFlag(OPT_fdisable_loc_tracking, OPT_INVALID, false);
opts.EnablePayloadQualifiers = Args.hasFlag(OPT_enable_payload_qualifiers, OPT_INVALID,
DXIL::CompareVersions(Major, Minor, 6, 7) >= 0);

Просмотреть файл

@ -561,6 +561,13 @@ BackendConsumer::DxilDiagHandler(const llvm::DiagnosticInfoDxil &D) {
auto *func = D.getFunction();
if (DiagClient && func)
DiagClient->setPrefix("Function: " + func->getName().str());
// Clang will de-duplicate this so that it only emits once.
Diags.Report(
Diags.getCustomDiagID(DiagnosticsEngine::Note,
"Debug information is disabled which may impact "
"diagnostic location accuracy. Re-run without "
"-fdisable-loc-tracking to improve accuracy.\n"));
}
Diags.Report(Loc, DiagID).AddString(Message);

Просмотреть файл

@ -0,0 +1,25 @@
// RUN: %dxc -T cs_6_0 -fdisable-loc-tracking %s 2>&1 | FileCheck %s
// CHECK: Function: main: note: Debug information is disabled which may impact diagnostic location accuracy. Re-run without -fdisable-loc-tracking to improve accuracy.
// CHECK-NOT: note: Debug information is disabled
RWBuffer<int> Buf[2];
RWBuffer<int> Out;
int getVal(bool B, int Idx) {
RWBuffer<int> Local;
if (B) Local = Buf[Idx];
return Local[Idx];
}
int getValASecondTime(bool B, int Idx) {
RWBuffer<int> Local;
if (B) Local = Buf[Idx];
return Local[Idx];
}
[numthreads(1,1,1)]
void main(uint GI : SV_GroupIndex) {
Out[GI] = getVal(false, GI);
Out[GI+1] = getValASecondTime(false, GI);
}

Просмотреть файл

@ -1423,7 +1423,7 @@ public:
// TODO: consider
// DebugPass, DebugCompilationDir, DwarfDebugFlags, SplitDwarfFile
}
else {
else if (!Opts.ForceDisableLocTracking) {
CodeGenOptions &CGOpts = compiler.getCodeGenOpts();
CGOpts.setDebugInfo(CodeGenOptions::LocTrackingOnly);
CGOpts.DebugColumnInfo = 1;