[clang] [CIR] Emit lifetime markers for automatic variables (PR #206695)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 30 06:40:38 PDT 2026
================
@@ -28,10 +28,30 @@
namespace clang::CIRGen {
+/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
+/// markers. Mirror of CodeGenFunction::shouldEmitLifetimeMarkers.
+static bool shouldEmitLifetimeMarkers(const CodeGenOptions &cgOpts,
+ const LangOptions &langOpts) {
+
+ if (cgOpts.DisableLifetimeMarkers)
+ return false;
+
+ // Sanitizers may use markers.
+ if (cgOpts.SanitizeAddressUseAfterScope ||
+ langOpts.Sanitize.has(SanitizerKind::HWAddress) ||
+ langOpts.Sanitize.has(SanitizerKind::Memory) ||
+ langOpts.Sanitize.has(SanitizerKind::MemtagStack))
+ return true;
+
+ return cgOpts.OptimizationLevel != 0;
----------------
Lancern wrote:
Could you add a lit test that verifies no lifetime markers are emitted under `-O0`?
https://github.com/llvm/llvm-project/pull/206695
More information about the cfe-commits
mailing list