[PATCH] D77189: Bisect autoinit

Vitaly Buka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 31 18:12:51 PDT 2020


vitalybuka created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77189

Files:
  clang/lib/CodeGen/CGDecl.cpp


Index: clang/lib/CodeGen/CGDecl.cpp
===================================================================
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -37,6 +37,7 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Type.h"
+#include <iostream>
 
 using namespace clang;
 using namespace CodeGen;
@@ -44,6 +45,11 @@
 static_assert(clang::Sema::MaximumAlignment <= llvm::Value::MaximumAlignment,
               "Clang max alignment greater than what LLVM supports?");
 
+#include "llvm/Support/CommandLine.h"
+static llvm::cl::opt<uint64_t> ClUninitBegin("uninit-begin", llvm::cl::init(1));
+static llvm::cl::opt<uint64_t> ClUninitEnd("uninit-end", llvm::cl::init(0));
+static llvm::cl::opt<bool> ClUninitPrint("uninit-print", llvm::cl::init(false));
+
 void CodeGenFunction::EmitDecl(const Decl &D) {
   switch (D.getKind()) {
   case Decl::BuiltinTemplate:
@@ -1793,13 +1799,26 @@
   const Address Loc =
       locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
+  static const uint64_t HB = ClUninitBegin;
+  static const uint64_t HE = ClUninitEnd;
+  size_t v = llvm::hash_value(
+      D.getLocation().printToString(getContext().getSourceManager()));
+  bool attr = D.getAttr<UninitializedAttr>();
+  if (v >= HB && v <= HE) {
+    if (ClUninitPrint) {
+      std::cerr << v << " "
+                << D.getLocation().printToString(
+                       getContext().getSourceManager())
+                << "\n";
+    }
+    attr = true;
+  }
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
       (D.isConstexpr()
            ? LangOptions::TrivialAutoVarInitKind::Uninitialized
-           : (D.getAttr<UninitializedAttr>()
-                  ? LangOptions::TrivialAutoVarInitKind::Uninitialized
-                  : getContext().getLangOpts().getTrivialAutoVarInit()));
+           : (attr ? LangOptions::TrivialAutoVarInitKind::Uninitialized
+                   : getContext().getLangOpts().getTrivialAutoVarInit()));
 
   auto initializeWhatIsTechnicallyUninitialized = [&](Address Loc) {
     if (trivialAutoVarInit ==


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77189.254064.patch
Type: text/x-patch
Size: 2189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200401/6fe3f212/attachment.bin>


More information about the cfe-commits mailing list