[llvm] fac26ed - Revert "[Assignment Tracking][3/*] Add DIAssignID metadata boilerplate"

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 06:49:21 PDT 2022


Author: OCHyams
Date: 2022-11-03T13:46:00Z
New Revision: fac26edae504555e383032fafd7921cb9d9a2022

URL: https://github.com/llvm/llvm-project/commit/fac26edae504555e383032fafd7921cb9d9a2022
DIFF: https://github.com/llvm/llvm-project/commit/fac26edae504555e383032fafd7921cb9d9a2022.diff

LOG: Revert "[Assignment Tracking][3/*] Add DIAssignID metadata boilerplate"

This reverts commit c285df77e9b78f971f9cd9d025248c20b030cc2a.

A sanitizer bot found an issue:
https://lab.llvm.org/buildbot/#/builders/5/builds/28809/steps/13/logs/stdio

Added: 
    

Modified: 
    llvm/include/llvm-c/DebugInfo.h
    llvm/include/llvm/Bitcode/LLVMBitCodes.h
    llvm/include/llvm/IR/DebugInfoMetadata.h
    llvm/include/llvm/IR/FixedMetadataKinds.def
    llvm/include/llvm/IR/Metadata.def
    llvm/lib/AsmParser/LLParser.cpp
    llvm/lib/Bitcode/Reader/MetadataLoader.cpp
    llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    llvm/lib/IR/AsmWriter.cpp
    llvm/lib/IR/DebugInfo.cpp
    llvm/lib/IR/DebugInfoMetadata.cpp
    llvm/lib/IR/Verifier.cpp

Removed: 
    llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/distinct.ll
    llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll
    llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/operands.ll
    llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/roundtrip.ll


################################################################################
diff  --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index ef6a147eb2a52..8554a01998736 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -169,8 +169,7 @@ enum {
   LLVMDICommonBlockMetadataKind,
   LLVMDIStringTypeMetadataKind,
   LLVMDIGenericSubrangeMetadataKind,
-  LLVMDIArgListMetadataKind,
-  LLVMDIAssignIDMetadataKind,
+  LLVMDIArgListMetadataKind
 };
 typedef unsigned LLVMMetadataKind;
 

diff  --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 74a51d5ce6907..ee5669c6c6aa8 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -349,8 +349,7 @@ enum MetadataCodes {
   // info.
   METADATA_COMMON_BLOCK = 44,     // [distinct, scope, name, variable,...]
   METADATA_GENERIC_SUBRANGE = 45, // [distinct, count, lo, up, stride]
-  METADATA_ARG_LIST = 46,         // [n x [type num, value num]]
-  METADATA_ASSIGN_ID = 47,        // [distinct, ...]
+  METADATA_ARG_LIST = 46          // [n x [type num, value num]]
 };
 
 // The constants block (CONSTANTS_BLOCK_ID) describes emission for each

diff  --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index f57691f6f9fc6..5b20bf3ade99a 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -215,7 +215,6 @@ class DINode : public MDNode {
     case DIImportedEntityKind:
     case DIModuleKind:
     case DIGenericSubrangeKind:
-    case DIAssignIDKind:
       return true;
     }
   }
@@ -296,41 +295,6 @@ class GenericDINode : public DINode {
   }
 };
 
-/// Assignment ID.
-/// Used to link stores (as an attachment) and dbg.assigns (as an operand).
-/// DIAssignID metadata is never uniqued as we compare instances using
-/// referential equality (the instance/address is the ID).
-class DIAssignID : public MDNode {
-  friend class LLVMContextImpl;
-  friend class MDNode;
-
-  DIAssignID(LLVMContext &C, StorageType Storage)
-      : MDNode(C, DIAssignIDKind, Storage, None) {}
-
-  ~DIAssignID() { dropAllReferences(); }
-
-  static DIAssignID *getImpl(LLVMContext &Context, StorageType Storage,
-                             bool ShouldCreate = true);
-
-  TempDIAssignID cloneImpl() const { return getTemporary(getContext()); }
-
-public:
-  // This node has no operands to replace.
-  void replaceOperandWith(unsigned I, Metadata *New) = delete;
-
-  static DIAssignID *getDistinct(LLVMContext &Context) {
-    return getImpl(Context, Distinct);
-  }
-  static TempDIAssignID getTemporary(LLVMContext &Context) {
-    return TempDIAssignID(getImpl(Context, Temporary));
-  }
-  // NOTE: Do not define get(LLVMContext&) - see class comment.
-
-  static bool classof(const Metadata *MD) {
-    return MD->getMetadataID() == DIAssignIDKind;
-  }
-};
-
 /// Array subrange.
 ///
 /// TODO: Merge into node for DW_TAG_array_type, which should have a custom

diff  --git a/llvm/include/llvm/IR/FixedMetadataKinds.def b/llvm/include/llvm/IR/FixedMetadataKinds.def
index 8723bf2a0680c..3d986325c5d33 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -49,4 +49,3 @@ LLVM_FIXED_MD_KIND(MD_memprof, "memprof", 34)
 LLVM_FIXED_MD_KIND(MD_callsite, "callsite", 35)
 LLVM_FIXED_MD_KIND(MD_kcfi_type, "kcfi_type", 36)
 LLVM_FIXED_MD_KIND(MD_pcsections, "pcsections", 37)
-LLVM_FIXED_MD_KIND(MD_DIAssignID, "DIAssignID", 38)

diff  --git a/llvm/include/llvm/IR/Metadata.def b/llvm/include/llvm/IR/Metadata.def
index 36c34c1d2347c..bbf349e6b508c 100644
--- a/llvm/include/llvm/IR/Metadata.def
+++ b/llvm/include/llvm/IR/Metadata.def
@@ -110,7 +110,6 @@ HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DILocalVariable)
 HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DILabel)
 HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIObjCProperty)
 HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIImportedEntity)
-HANDLE_SPECIALIZED_MDNODE_LEAF(DIAssignID)
 HANDLE_SPECIALIZED_MDNODE_BRANCH(DIMacroNode)
 HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIMacro)
 HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIMacroFile)

diff  --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 43e47aa33c863..0fda0559b5b41 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -4646,24 +4646,6 @@ bool LLParser::parseDILocation(MDNode *&Result, bool IsDistinct) {
   return false;
 }
 
-/// parseDIAssignID:
-///   ::= distinct !DIAssignID()
-bool LLParser::parseDIAssignID(MDNode *&Result, bool IsDistinct) {
-  if (!IsDistinct)
-    return Lex.Error("missing 'distinct', required for !DIAssignID()");
-
-  Lex.Lex();
-
-  // Now eat the parens.
-  if (parseToken(lltok::lparen, "expected '(' here"))
-    return true;
-  if (parseToken(lltok::rparen, "expected ')' here"))
-    return true;
-
-  Result = DIAssignID::getDistinct(Context);
-  return false;
-}
-
 /// parseGenericDINode:
 ///   ::= !GenericDINode(tag: 15, header: "...", operands: {...})
 bool LLParser::parseGenericDINode(MDNode *&Result, bool IsDistinct) {

diff  --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 1ac1502e8aefb..02d76f61695af 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -856,7 +856,6 @@ MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
       case bitc::METADATA_TEMPLATE_VALUE:
       case bitc::METADATA_GLOBAL_VAR:
       case bitc::METADATA_LOCAL_VAR:
-      case bitc::METADATA_ASSIGN_ID:
       case bitc::METADATA_LABEL:
       case bitc::METADATA_EXPRESSION:
       case bitc::METADATA_OBJC_PROPERTY:
@@ -1965,18 +1964,6 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
 
     break;
   }
-  case bitc::METADATA_ASSIGN_ID: {
-    if (Record.size() != 1)
-      return error("Invalid DIAssignID record.");
-
-    IsDistinct = Record[0] & 1;
-    if (!IsDistinct)
-      return error("Invalid DIAssignID record. Must be distinct");
-
-    MetadataList.assignValue(DIAssignID::getDistinct(Context), NextMetadataNo);
-    NextMetadataNo++;
-    break;
-  }
   case bitc::METADATA_LOCAL_VAR: {
     // 10th field is for the obseleted 'inlinedAt:' field.
     if (Record.size() < 8 || Record.size() > 10)

diff  --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index bed3ebad9874e..1ac4413f158eb 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -340,8 +340,6 @@ class ModuleBitcodeWriter : public ModuleBitcodeWriterBase {
                       unsigned Abbrev);
   void writeDIModule(const DIModule *N, SmallVectorImpl<uint64_t> &Record,
                      unsigned Abbrev);
-  void writeDIAssignID(const DIAssignID *N, SmallVectorImpl<uint64_t> &Record,
-                       unsigned Abbrev);
   void writeDITemplateTypeParameter(const DITemplateTypeParameter *N,
                                     SmallVectorImpl<uint64_t> &Record,
                                     unsigned Abbrev);
@@ -1957,15 +1955,6 @@ void ModuleBitcodeWriter::writeDIModule(const DIModule *N,
   Record.clear();
 }
 
-void ModuleBitcodeWriter::writeDIAssignID(const DIAssignID *N,
-                                          SmallVectorImpl<uint64_t> &Record,
-                                          unsigned Abbrev) {
-  // There are no arguments for this metadata type.
-  Record.push_back(N->isDistinct());
-  Stream.EmitRecord(bitc::METADATA_ASSIGN_ID, Record, Abbrev);
-  Record.clear();
-}
-
 void ModuleBitcodeWriter::writeDITemplateTypeParameter(
     const DITemplateTypeParameter *N, SmallVectorImpl<uint64_t> &Record,
     unsigned Abbrev) {

diff  --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index d49b8710bc9a4..21e662bed6b25 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1865,12 +1865,6 @@ static void writeDILocation(raw_ostream &Out, const DILocation *DL,
   Out << ")";
 }
 
-static void writeDIAssignID(raw_ostream &Out, const DIAssignID *DL,
-                            AsmWriterContext &WriterCtx) {
-  Out << "!DIAssignID()";
-  MDFieldPrinter Printer(Out, WriterCtx);
-}
-
 static void writeDISubrange(raw_ostream &Out, const DISubrange *N,
                             AsmWriterContext &WriterCtx) {
   Out << "!DISubrange(";

diff  --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index d30fca63067c0..8f6d58cb90b90 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -469,13 +469,9 @@ bool llvm::stripDebugInfo(Function &F) {
         if (NewLoopID != LoopID)
           I.setMetadata(LLVMContext::MD_loop, NewLoopID);
       }
-      // Strip other attachments that are or use debug info.
-      if (I.hasMetadataOtherThanDebugLoc()) {
-        // Heapallocsites point into the DIType system.
+      // Strip heapallocsite attachments, they point into the DIType system.
+      if (I.hasMetadataOtherThanDebugLoc())
         I.setMetadata("heapallocsite", nullptr);
-        // DIAssignID are debug info metadata primitives.
-        I.setMetadata(LLVMContext::MD_DIAssignID, nullptr);
-      }
     }
   }
   return Changed;

diff  --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index 2359e56c08684..9b4f92a63c5e2 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -1253,13 +1253,6 @@ bool DIExpression::startsWithDeref() const {
   return getNumElements() > 0 && getElement(0) == dwarf::DW_OP_deref;
 }
 
-DIAssignID *DIAssignID::getImpl(LLVMContext &Context, StorageType Storage,
-                                bool ShouldCreate) {
-  // Uniqued DIAssignID are not supported as the instance address *is* the ID.
-  assert(Storage != StorageType::Uniqued && "uniqued DIAssignID unsupported");
-  return new (0u, Storage) DIAssignID(Context, Storage);
-}
-
 unsigned DIExpression::ExprOperand::getSize() const {
   uint64_t Op = getOp();
 

diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index c9b2d6aa5abf2..0614f206981a1 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -471,7 +471,6 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
   void visitCallStackMetadata(MDNode *MD);
   void visitMemProfMetadata(Instruction &I, MDNode *MD);
   void visitCallsiteMetadata(Instruction &I, MDNode *MD);
-  void visitDIAssignIDMetadata(Instruction &I, MDNode *MD);
   void visitAnnotationMetadata(MDNode *Annotation);
   void visitAliasScopeMetadata(const MDNode *MD);
   void visitAliasScopeListMetadata(const MDNode *MD);
@@ -1484,11 +1483,6 @@ void Verifier::visitDILocalVariable(const DILocalVariable &N) {
     CheckDI(!isa<DISubroutineType>(Ty), "invalid type", &N, N.getType());
 }
 
-void Verifier::visitDIAssignID(const DIAssignID &N) {
-  CheckDI(!N.getNumOperands(), "DIAssignID has no arguments", &N);
-  CheckDI(N.isDistinct(), "DIAssignID must be distinct", &N);
-}
-
 void Verifier::visitDILabel(const DILabel &N) {
   if (auto *S = N.getRawScope())
     CheckDI(isa<DIScope>(S), "invalid scope", &N, S);
@@ -4555,14 +4549,6 @@ void Verifier::visitProfMetadata(Instruction &I, MDNode *MD) {
   }
 }
 
-void Verifier::visitDIAssignIDMetadata(Instruction &I, MDNode *MD) {
-  assert(I.hasMetadata(LLVMContext::MD_DIAssignID));
-  bool ExpectedInstTy =
-      isa<AllocaInst>(I) || isa<StoreInst>(I) || isa<MemIntrinsic>(I);
-  CheckDI(ExpectedInstTy, "!DIAssignID attached to unexpected instruction kind",
-          I, MD);
-}
-
 void Verifier::visitCallStackMetadata(MDNode *MD) {
   // Call stack metadata should consist of a list of at least 1 constant int
   // (representing a hash of the location).
@@ -4864,9 +4850,6 @@ void Verifier::visitInstruction(Instruction &I) {
   if (MDNode *MD = I.getMetadata(LLVMContext::MD_callsite))
     visitCallsiteMetadata(I, MD);
 
-  if (MDNode *MD = I.getMetadata(LLVMContext::MD_DIAssignID))
-    visitDIAssignIDMetadata(I, MD);
-
   if (MDNode *Annotation = I.getMetadata(LLVMContext::MD_annotation))
     visitAnnotationMetadata(Annotation);
 

diff  --git a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/distinct.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/distinct.ll
deleted file mode 100644
index 2cc5452fe7d2a..0000000000000
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/distinct.ll
+++ /dev/null
@@ -1,9 +0,0 @@
-; RUN: not opt -S %s -experimental-assignment-tracking 2>&1 \
-; RUN: | FileCheck %s
-
-;; Check that badly formed assignment tracking metadata is caught either
-;; while parsing or by the verifier.
-
-; CHECK: error: missing 'distinct', required for !DIAssignID()
-
-!1 = !DIAssignID()

diff  --git a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll
deleted file mode 100644
index d0f447ee200b6..0000000000000
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/instruction-type.ll
+++ /dev/null
@@ -1,36 +0,0 @@
-; RUN: opt -S %s -verify -experimental-assignment-tracking 2>&1 \
-; RUN: | FileCheck %s
-
-;; NOTE: Expect opt to return zero because the badly formed debug info
-;; is going to be stripped.
-
-;; Check that badly formed assignment tracking metadata is caught either
-;; while parsing or by the verifier.
-
-;; Check verifier output.
-; CHECK: !DIAssignID attached to unexpected instruction kind
-
-;; Check DIAssignID is stripped from IR.
-; CHECK: define dso_local void @fun() {
-; CHECK-NOT: DIAssignID
-
-define dso_local void @fun() !dbg !7 {
-entry:
-  ret void, !DIAssignID !14
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4, !5}
-!llvm.ident = !{!6}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "test.c", directory: "/")
-!2 = !{}
-!3 = !{i32 7, !"Dwarf Version", i32 4}
-!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = !{i32 1, !"wchar_size", i32 4}
-!6 = !{!"clang version 14.0.0"}
-!7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
-!8 = !DISubroutineType(types: !9)
-!9 = !{null}
-!14 = distinct !DIAssignID()

diff  --git a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/operands.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/operands.ll
deleted file mode 100644
index 79adcb9ce2d12..0000000000000
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/operands.ll
+++ /dev/null
@@ -1,9 +0,0 @@
-; RUN: not opt -S %s -experimental-assignment-tracking 2>&1 \
-; RUN: | FileCheck %s
-
-;; Check that badly formed assignment tracking metadata is caught either
-;; while parsing or by the verifier.
-
-; CHECK: error: expected ')' here
-
-!1 = distinct !DIAssignID(0)

diff  --git a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/roundtrip.ll b/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/roundtrip.ll
deleted file mode 100644
index 1ddb95b79b0f0..0000000000000
--- a/llvm/test/DebugInfo/Generic/assignment-tracking/parse-and-verify/roundtrip.ll
+++ /dev/null
@@ -1,33 +0,0 @@
-; RUN: opt %s -verify -experimental-assignment-tracking   \
-; RUN: | opt -verify -S -experimental-assignment-tracking \
-; RUN: | FileCheck %s
-
-;; Roundtrip test (text -> bitcode -> text) for DIAssignID attachments.
-
-; CHECK: %local = alloca i32, align 4, !DIAssignID ![[ID:[0-9]+]]
-; CHECK-DAG: ![[ID]] = distinct !DIAssignID()
-
-define dso_local void @fun() !dbg !7 {
-entry:
-  %local = alloca i32, align 4, !DIAssignID !14
-  ret void, !dbg !13
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3, !4, !5}
-!llvm.ident = !{!6}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "test.c", directory: "/")
-!2 = !{}
-!3 = !{i32 7, !"Dwarf Version", i32 4}
-!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = !{i32 1, !"wchar_size", i32 4}
-!6 = !{!"clang version 14.0.0"}
-!7 = distinct !DISubprogram(name: "fun", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
-!8 = !DISubroutineType(types: !9)
-!9 = !{null}
-!10 = !DILocalVariable(name: "local", scope: !7, file: !1, line: 2, type: !11)
-!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!13 = !DILocation(line: 3, column: 1, scope: !7)
-!14 = distinct !DIAssignID()


        


More information about the llvm-commits mailing list