فهرست منبع

Add hidden option to disable lifetime markers (#3406)

Intended for debugging and workarounds
Greg Roth 4 سال پیش
والد
کامیت
f68dfb5092

+ 2 - 0
include/dxc/Support/HLSLOptions.td

@@ -275,6 +275,8 @@ def force_zero_store_lifetimes : Flag<["-", "/"], "force-zero-store-lifetimes">,
   HelpText<"Instead of generating lifetime intrinsics (SM >= 6.6) or storing undef (SM < 6.6), force fall back to storing zeroinitializer.">;
 def enable_lifetime_markers : Flag<["-", "/"], "enable-lifetime-markers">, Group<hlslcomp_Group>, Flags<[CoreOption]>,
   HelpText<"Enable generation of lifetime markers">;
+def disable_lifetime_markers : Flag<["-", "/"], "disable-lifetime-markers">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
+  HelpText<"Disable generation of lifetime markers where they would be otherwise (6.6+)">;
 
 // Used with API only
 def skip_serialization : Flag<["-", "/"], "skip-serialization">, Group<hlslcore_Group>, Flags<[CoreOption, HelpHidden]>,

+ 3 - 1
lib/DxcSupport/HLSLOptions.cpp

@@ -645,8 +645,10 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
   opts.ResMayAlias = Args.hasFlag(OPT_res_may_alias, OPT_INVALID, false);
   opts.ResMayAlias = Args.hasFlag(OPT_res_may_alias_, OPT_INVALID, opts.ResMayAlias);
   opts.ForceZeroStoreLifetimes = Args.hasFlag(OPT_force_zero_store_lifetimes, OPT_INVALID, false);
+  // Lifetime markers on by default in 6.6 unless disabled explicitly
   opts.EnableLifetimeMarkers = Args.hasFlag(OPT_enable_lifetime_markers, OPT_INVALID,
-                                            DXIL::CompareVersions(Major, Minor, 6, 6) >= 0);
+                                            DXIL::CompareVersions(Major, Minor, 6, 6) >= 0) &&
+                               !Args.hasFlag(OPT_disable_lifetime_markers, OPT_INVALID, false);
 
   if (opts.DefaultColMajor && opts.DefaultRowMajor) {
     errors << "Cannot specify /Zpr and /Zpc together, use /? to get usage information";

+ 3 - 0
tools/clang/test/HLSLFileCheck/hlsl/lifetimes/lifetimes.hlsl

@@ -1,4 +1,7 @@
 // RUN: %dxc -T lib_6_6 %s  | FileCheck %s
+// RUN: %dxc -disable-lifetime-markers -T lib_6_6 %s  | FileCheck %s -check-prefix=NOLIFE
+
+// NOLIFE-NOT: @llvm.lifetime
 
 //
 // Non-SSA arrays should have lifetimes within the correct scope.