[clang] [Clang] Initialize bypassed variables w/ trivial-auto-var-init (PR #181937)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 14:54:32 PDT 2026


================
@@ -1544,8 +1544,12 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
       ShouldEmitLifetimeMarkers = true;
 
     // Initialize helper which will detect jumps which can cause invalid
-    // lifetime markers.
-    if (ShouldEmitLifetimeMarkers)
+    // lifetime markers or bypass trivial auto var init.
+    bool NeedsBypassDetection =
+        ShouldEmitLifetimeMarkers ||
+        (CGM.getLangOpts().getTrivialAutoVarInit() !=
+         LangOptions::TrivialAutoVarInitKind::Uninitialized);
+    if (NeedsBypassDetection)
       Bypasses.Init(CGM, Body);
----------------
efriedma-quic wrote:

That's what I was afraid of.

If we have to take some penalty, I guess I'm okay with that, but I'd appreciate if you can investigate a bit.  Is there some way we can reduce the amount of work VarBypassDetector does?  Maybe have Sema set a flag if it sees certain constructs?

https://github.com/llvm/llvm-project/pull/181937


More information about the cfe-commits mailing list