[llvm] c862e61 - Revert "[RemoveDIs] Enable DPLabels conversion [3b/3] (#82639)"

Jorge Gorbe Moya via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 16:44:14 PST 2024


Author: Jorge Gorbe Moya
Date: 2024-02-23T16:43:07-08:00
New Revision: c862e612068c9c33995a2e2d289ced44b8eba810

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

LOG: Revert "[RemoveDIs] Enable DPLabels conversion [3b/3] (#82639)"

This reverts commit 71d47a0b00e9f48dc740556d7f452ffadf308731 because
it causes clang to crash in some cases. See repro posted at
https://github.com/llvm/llvm-project/commit/71d47a0b00e9f48dc740556d7f452ffadf308731

Added: 
    

Modified: 
    llvm/include/llvm/IR/DebugProgramInstruction.h
    llvm/lib/IR/BasicBlock.cpp
    llvm/lib/IR/DebugProgramInstruction.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/DebugProgramInstruction.h b/llvm/include/llvm/IR/DebugProgramInstruction.h
index 97089098ee5352..84b0f743d3c9b9 100644
--- a/llvm/include/llvm/IR/DebugProgramInstruction.h
+++ b/llvm/include/llvm/IR/DebugProgramInstruction.h
@@ -62,8 +62,6 @@ class BasicBlock;
 class MDNode;
 class Module;
 class DbgVariableIntrinsic;
-class DbgInfoIntrinsic;
-class DbgLabelInst;
 class DIAssignID;
 class DPMarker;
 class DPValue;
@@ -82,7 +80,6 @@ class raw_ostream;
 ///   clone
 ///   isIdenticalToWhenDefined
 ///   both print methods
-///   createDebugIntrinsic
 class DbgRecord : public ilist_node<DbgRecord> {
 public:
   /// Marker that this DbgRecord is linked into.
@@ -106,11 +103,6 @@ class DbgRecord : public ilist_node<DbgRecord> {
   void print(raw_ostream &O, bool IsForDebug = false) const;
   void print(raw_ostream &O, ModuleSlotTracker &MST, bool IsForDebug) const;
   bool isIdenticalToWhenDefined(const DbgRecord &R) const;
-  /// Convert this DbgRecord back into an appropriate llvm.dbg.* intrinsic.
-  /// \p InsertBefore Optional position to insert this intrinsic.
-  /// \returns A new llvm.dbg.* intrinsic representiung this DbgRecord.
-  DbgInfoIntrinsic *createDebugIntrinsic(Module *M,
-                                         Instruction *InsertBefore) const;
   ///@}
 
   /// Same as isIdenticalToWhenDefined but checks DebugLoc too.
@@ -185,8 +177,6 @@ class DPLabel : public DbgRecord {
   DPLabel *clone() const;
   void print(raw_ostream &O, bool IsForDebug = false) const;
   void print(raw_ostream &ROS, ModuleSlotTracker &MST, bool IsForDebug) const;
-  DbgLabelInst *createDebugIntrinsic(Module *M,
-                                     Instruction *InsertBefore) const;
 
   void setLabel(DILabel *NewLabel) { Label = NewLabel; }
   DILabel *getLabel() const { return Label; }

diff  --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 6ea876fde5ec66..0680754444f17f 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -81,12 +81,6 @@ void BasicBlock::convertToNewDbgValues() {
       continue;
     }
 
-    if (DbgLabelInst *DLI = dyn_cast<DbgLabelInst>(&I)) {
-      DPVals.push_back(new DPLabel(DLI->getLabel(), DLI->getDebugLoc()));
-      DLI->eraseFromParent();
-      continue;
-    }
-
     if (DPVals.empty())
       continue;
 
@@ -113,12 +107,16 @@ void BasicBlock::convertFromNewDbgValues() {
       continue;
 
     DPMarker &Marker = *Inst.DbgMarker;
-    for (DbgRecord &DR : Marker.getDbgValueRange())
-      InstList.insert(Inst.getIterator(),
-                      DR.createDebugIntrinsic(getModule(), nullptr));
+    for (DbgRecord &DR : Marker.getDbgValueRange()) {
+      if (auto *DPV = dyn_cast<DPValue>(&DR))
+        InstList.insert(Inst.getIterator(),
+                        DPV->createDebugIntrinsic(getModule(), nullptr));
+      else
+        llvm_unreachable("unsupported DbgRecord kind");
+    }
 
     Marker.eraseFromParent();
-  }
+  };
 
   // Assume no trailing DPValues: we could technically create them at the end
   // of the block, after a terminator, but this would be non-cannonical and

diff  --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp
index 389bac4de6a1cb..2ca4533afa96c9 100644
--- a/llvm/lib/IR/DebugProgramInstruction.cpp
+++ b/llvm/lib/IR/DebugProgramInstruction.cpp
@@ -112,17 +112,6 @@ bool DbgRecord::isEquivalentTo(const DbgRecord &R) const {
   return getDebugLoc() == R.getDebugLoc() && isIdenticalToWhenDefined(R);
 }
 
-DbgInfoIntrinsic *
-DbgRecord::createDebugIntrinsic(Module *M, Instruction *InsertBefore) const {
-  switch (RecordKind) {
-  case ValueKind:
-    return cast<DPValue>(this)->createDebugIntrinsic(M, InsertBefore);
-  case LabelKind:
-    return cast<DPLabel>(this)->createDebugIntrinsic(M, InsertBefore);
-  };
-  llvm_unreachable("unsupported DbgRecord kind");
-}
-
 DPValue *DPValue::createDPValue(Value *Location, DILocalVariable *DV,
                                 DIExpression *Expr, const DILocation *DI) {
   return new DPValue(ValueAsMetadata::get(Location), DV, Expr, DI,
@@ -388,20 +377,6 @@ DPValue::createDebugIntrinsic(Module *M, Instruction *InsertBefore) const {
   return DVI;
 }
 
-DbgLabelInst *DPLabel::createDebugIntrinsic(Module *M,
-                                            Instruction *InsertBefore) const {
-  auto *LabelFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_label);
-  Value *Args[] = {
-      MetadataAsValue::get(getDebugLoc()->getContext(), getLabel())};
-  DbgLabelInst *DbgLabel = cast<DbgLabelInst>(
-      CallInst::Create(LabelFn->getFunctionType(), LabelFn, Args));
-  DbgLabel->setTailCall();
-  DbgLabel->setDebugLoc(getDebugLoc());
-  if (InsertBefore)
-    DbgLabel->insertBefore(InsertBefore);
-  return DbgLabel;
-}
-
 Value *DPValue::getAddress() const {
   auto *MD = getRawAddress();
   if (auto *V = dyn_cast<ValueAsMetadata>(MD))


        


More information about the llvm-commits mailing list