Skip to content

Commit 7a4c36e

Browse files
authored
Merge pull request #59074 from slavapestov/type-reconstruction-round-trip-flag
IRGen: Add -enable/disable-round-trip-debug-types flag, on by default in asserts builds
2 parents b9e8e2c + b45e0d1 commit 7a4c36e

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ class IRGenOptions {
462462
PrespecializeGenericMetadata(false), UseIncrementalLLVMCodeGen(true),
463463
UseTypeLayoutValueHandling(true), ForceStructTypeLayouts(false),
464464
GenerateProfile(false), EnableDynamicReplacementChaining(false),
465-
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
465+
DisableDebuggerShadowCopies(false),
466466
DisableConcreteTypeMetadataMangledNameAccessors(false),
467467
DisableStandardSubstitutionsInReflectionMangling(false),
468468
EnableGlobalISel(false), VirtualFunctionElimination(false),
@@ -471,7 +471,13 @@ class IRGenOptions {
471471
NoPreallocatedInstantiationCaches(false),
472472
CmdArgs(),
473473
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
474-
TypeInfoFilter(TypeInfoDumpFilter::All) {}
474+
TypeInfoFilter(TypeInfoDumpFilter::All) {
475+
#ifndef NDEBUG
476+
DisableRoundTripDebugTypes = false;
477+
#else
478+
DisableRoundTripDebugTypes = true;
479+
#endif
480+
}
475481

476482
/// Appends to \p os an arbitrary string representing all options which
477483
/// influence the llvm compilation but are not reflected in the llvm module

include/swift/Option/FrontendOptions.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ def warn_redundant_requirements : Flag<["-"], "warn-redundant-requirements">,
388388
def dump_type_witness_systems : Flag<["-"], "dump-type-witness-systems">,
389389
HelpText<"Enables dumping type witness systems from associated type inference">;
390390

391+
def enable_round_trip_debug_types : Flag<["-"], "enable-round-trip-debug-types">,
392+
HelpText<"Enables verification of debug info mangling">;
393+
394+
def disable_round_trip_debug_types : Flag<["-"], "disable-round-trip-debug-types">,
395+
HelpText<"Disables verification of debug info mangling">;
396+
391397
def debug_generic_signatures : Flag<["-"], "debug-generic-signatures">,
392398
HelpText<"Debug generic signatures">;
393399

lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,6 +2045,12 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
20452045
if (Args.hasArg(OPT_no_clang_module_breadcrumbs))
20462046
Opts.DisableClangModuleSkeletonCUs = true;
20472047

2048+
if (auto A = Args.getLastArg(OPT_enable_round_trip_debug_types,
2049+
OPT_disable_round_trip_debug_types)) {
2050+
Opts.DisableRoundTripDebugTypes =
2051+
Args.hasArg(OPT_disable_round_trip_debug_types);
2052+
}
2053+
20482054
if (Args.hasArg(OPT_disable_debugger_shadow_copies))
20492055
Opts.DisableDebuggerShadowCopies = true;
20502056

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
915915
if (!Opts.DisableRoundTripDebugTypes &&
916916
!Ty->getASTContext().LangOpts.EnableCXXInterop) {
917917
// Make sure we can reconstruct mangled types for the debugger.
918-
#ifndef NDEBUG
919918
auto &Ctx = Ty->getASTContext();
920919
Type Reconstructed = Demangle::getTypeForMangling(Ctx, Result);
921920
if (!Reconstructed) {
@@ -936,7 +935,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
936935
Reconstructed->dump(llvm::errs());
937936
abort();
938937
}
939-
#endif
940938
}
941939

942940
return BumpAllocatedString(Result);

0 commit comments

Comments
 (0)