https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/231379

This patch removes leftover code for legacy debug intrinsics
(DbgInfoIntrinsic and its subclasses) in two categories:

- Conditional checks, assertions, and switch cases that never trigger
  because debug intrinsics do not appear in these passes.
- Unused member functions on DbgVariableIntrinsic, DbgValueInst, and
  DbgAssignIntrinsic, along with the unimplemented
  Verifier::visitDbgLabelIntrinsic declaration.

Note that this patch leaves the DirectX backend alone for now because
it still converts DbgRecord objects back into debug intrinsics during
DXIL lowering.

Assisted-by: Antigravity


>From e5bc63d5a0281f8ccff1e1cbc78bd008d87b6b36 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <[email protected]>
Date: Mon, 12 Oct 2026 01:13:16 -0700
Subject: [PATCH] [DebugInfo] Remove dead debug intrinsic handling (NFC)

This patch removes leftover code for legacy debug intrinsics
(DbgInfoIntrinsic and its subclasses) in two categories:

- Conditional checks, assertions, and switch cases that never trigger
  because debug intrinsics do not appear in these passes.
- Unused member functions on DbgVariableIntrinsic, DbgValueInst, and
  DbgAssignIntrinsic, along with the unimplemented
  Verifier::visitDbgLabelIntrinsic declaration.

Note that this patch leaves the DirectX backend alone for now because
it still converts DbgRecord objects back into debug intrinsics during
DXIL lowering.

Assisted-by: Antigravity
---
 clang/lib/CodeGen/CGStmtOpenMP.cpp            |  3 --
 clang/lib/CodeGen/CGVTables.cpp               |  5 ---
 .../llvm/Analysis/TargetTransformInfoImpl.h   |  4 ---
 llvm/include/llvm/IR/DebugInfo.h              |  3 --
 llvm/include/llvm/IR/IntrinsicInst.h          | 35 -------------------
 llvm/lib/Analysis/MemorySSA.cpp               |  4 ---
 llvm/lib/Analysis/ObjCARCInstKind.cpp         |  4 ---
 llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp  | 32 -----------------
 llvm/lib/CodeGen/IntrinsicLowering.cpp        |  4 ---
 llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp     |  5 +--
 llvm/lib/IR/IntrinsicInst.cpp                 | 15 --------
 llvm/lib/IR/Verifier.cpp                      |  1 -
 llvm/lib/Target/X86/X86FastISel.cpp           | 15 --------
 llvm/lib/Transforms/Scalar/ADCE.cpp           | 27 --------------
 .../Scalar/DeadStoreElimination.cpp           |  4 ---
 llvm/lib/Transforms/Scalar/GVN.cpp            |  2 --
 llvm/lib/Transforms/Scalar/SROA.cpp           |  5 +--
 llvm/lib/Transforms/Utils/Local.cpp           | 11 +-----
 llvm/lib/Transforms/Utils/SimplifyCFG.cpp     | 13 +------
 .../llvm-reduce/deltas/ReduceMetadata.cpp     |  8 ++---
 polly/lib/CodeGen/BlockGenerators.cpp         |  6 ----
 polly/lib/Support/ScopHelper.cpp              |  3 --
 22 files changed, 6 insertions(+), 203 deletions(-)

diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 0913f76018a58..b8fdcee65bf93 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -35,7 +35,6 @@
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/Support/AtomicOrdering.h"
 #include "llvm/Support/Debug.h"
@@ -5588,8 +5587,6 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
             Declare->setExpression(llvm::DIExpression::get(Ctx, Ops));
           };
           llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back();
-          if (auto DDI = dyn_cast<llvm::DbgVariableIntrinsic>(&Last))
-            UpdateExpr(DDI->getContext(), DDI, Offset);
           // If we're emitting using the new debug info format into a block
           // without a terminator, the record will be "trailing".
           assert(!Last.isTerminator() && "unexpected terminator");
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index f0c48eba1f5c3..1aa3fb1928279 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -21,8 +21,6 @@
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/CodeGen/ConstantInitBuilder.h"
 #include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Intrinsics.h"
 #include "llvm/Transforms/Utils/Cloning.h"
 #include <algorithm>
 #include <cstdio>
@@ -165,9 +163,6 @@ static void resolveTopLevelMetadata(llvm::Function *Fn,
       for (llvm::DbgVariableRecord &DVR :
            llvm::filterDbgVars(I.getDbgRecordRange()))
         PrepareVariableMapping(DVR.getVariable());
-
-      if (auto *DII = dyn_cast<llvm::DbgVariableIntrinsic>(&I))
-        PrepareVariableMapping(DII->getVariable());
     }
   }
 }
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h 
b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 90e51fd27d8d2..b7b9ba23f50d9 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -945,10 +945,6 @@ class LLVM_ABI TargetTransformInfoImplBase {
     case Intrinsic::sideeffect:
     case Intrinsic::pseudoprobe:
     case Intrinsic::arithmetic_fence:
-    case Intrinsic::dbg_assign:
-    case Intrinsic::dbg_declare:
-    case Intrinsic::dbg_value:
-    case Intrinsic::dbg_label:
     case Intrinsic::invariant_start:
     case Intrinsic::invariant_end:
     case Intrinsic::launder_invariant_group:
diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h
index 5f1c49703040a..cd95ab796311b 100644
--- a/llvm/include/llvm/IR/DebugInfo.h
+++ b/llvm/include/llvm/IR/DebugInfo.h
@@ -32,9 +32,6 @@
 
 namespace llvm {
 
-class DbgDeclareInst;
-class DbgValueInst;
-class DbgVariableIntrinsic;
 class DbgVariableRecord;
 class Instruction;
 class Module;
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h 
b/llvm/include/llvm/IR/IntrinsicInst.h
index 5768e959e8872..cfb4bf04da49d 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -335,14 +335,6 @@ class DbgVariableIntrinsic : public DbgInfoIntrinsic {
 
   bool hasArgList() const { return getWrappedLocation().hasArgList(); }
 
-  /// Determine if this describes the value of a local variable. It is true for
-  /// dbg.value, but false for dbg.declare, which describes its address, and
-  /// false for dbg.assign, which describes a combination of the variable's
-  /// value and address.
-  bool isValueOfVariable() const {
-    return getIntrinsicID() == Intrinsic::dbg_value;
-  }
-
   bool isKillLocation() const {
     return getWrappedLocation().isKillLocation(getExpression());
   }
@@ -371,28 +363,6 @@ class DbgVariableIntrinsic : public DbgInfoIntrinsic {
     return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
   }
 
-  /// Get the size (in bits) of the variable, or fragment of the variable that
-  /// is described.
-  LLVM_ABI std::optional<uint64_t> getFragmentSizeInBits() const;
-
-  /// Get the FragmentInfo for the variable.
-  std::optional<DIExpression::FragmentInfo> getFragment() const {
-    return getExpression()->getFragmentInfo();
-  }
-
-  /// Get the FragmentInfo for the variable if it exists, otherwise return a
-  /// FragmentInfo that covers the entire variable if the variable size is
-  /// known, otherwise return a zero-sized fragment.
-  DIExpression::FragmentInfo getFragmentOrEntireVariable() const {
-    DIExpression::FragmentInfo VariableSlice(0, 0);
-    // Get the fragment or variable size, or zero.
-    if (auto Sz = getFragmentSizeInBits())
-      VariableSlice.SizeInBits = *Sz;
-    if (auto Frag = getExpression()->getFragmentInfo())
-      VariableSlice.OffsetInBits = Frag->OffsetInBits;
-    return VariableSlice;
-  }
-
   /// \name Casting methods
   /// @{
   static bool classof(const IntrinsicInst *I) {
@@ -444,9 +414,6 @@ class DbgValueInst : public DbgVariableIntrinsic {
   Value *getValue(unsigned OpIdx = 0) const {
     return getVariableLocationOp(OpIdx);
   }
-  iterator_range<location_op_iterator> getValues() const {
-    return location_ops();
-  }
 
   /// \name Casting methods
   /// @{
@@ -486,9 +453,7 @@ class DbgAssignIntrinsic : public DbgValueInst {
   DIExpression *getAddressExpression() const {
     return cast<DIExpression>(getRawAddressExpression());
   }
-  LLVM_ABI void setAssignId(DIAssignID *New);
   LLVM_ABI void setAddress(Value *V);
-  LLVM_ABI void setValue(Value *V);
   /// \name Casting methods
   /// @{
   static bool classof(const IntrinsicInst *I) {
diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp
index ebe10b9073a00..c5758b3064542 100644
--- a/llvm/lib/Analysis/MemorySSA.cpp
+++ b/llvm/lib/Analysis/MemorySSA.cpp
@@ -294,10 +294,6 @@ instructionClobbersQuery(const MemoryDef *MD, const 
MemoryLocation &UseLoc,
     case Intrinsic::experimental_noalias_scope_decl:
     case Intrinsic::pseudoprobe:
       return false;
-    case Intrinsic::dbg_declare:
-    case Intrinsic::dbg_label:
-    case Intrinsic::dbg_value:
-      llvm_unreachable("debuginfo shouldn't have associated defs!");
     default:
       break;
     }
diff --git a/llvm/lib/Analysis/ObjCARCInstKind.cpp 
b/llvm/lib/Analysis/ObjCARCInstKind.cpp
index fcc2c00725079..c6ec884166ef2 100644
--- a/llvm/lib/Analysis/ObjCARCInstKind.cpp
+++ b/llvm/lib/Analysis/ObjCARCInstKind.cpp
@@ -181,10 +181,6 @@ static bool isInertIntrinsic(unsigned ID) {
   case Intrinsic::lifetime_end:
   case Intrinsic::invariant_start:
   case Intrinsic::invariant_end:
-  // Don't let dbg info affect our results.
-  case Intrinsic::dbg_declare:
-  case Intrinsic::dbg_value:
-  case Intrinsic::dbg_label:
     // Short cut: Some intrinsics obviously don't use ObjC pointers.
     return true;
   default:
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp 
b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index a18292dddbe9e..3447dab594cae 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -3074,24 +3074,6 @@ bool IRTranslatorImpl::translateKnownIntrinsic(const 
CallInst &CI,
     MF->setHasFakeUses(true);
     return true;
   }
-  case Intrinsic::dbg_declare: {
-    const DbgDeclareInst &DI = cast<DbgDeclareInst>(CI);
-    assert(DI.getVariable() && "Missing variable");
-    translateDbgDeclareRecord(DI.getAddress(), DI.hasArgList(), 
DI.getVariable(),
-                       DI.getExpression(), DI.getDebugLoc(), MIRBuilder);
-    return true;
-  }
-  case Intrinsic::dbg_label: {
-    const DbgLabelInst &DI = cast<DbgLabelInst>(CI);
-    assert(DI.getLabel() && "Missing label");
-
-    assert(DI.getLabel()->isValidLocationForIntrinsic(
-               MIRBuilder.getDebugLoc()) &&
-           "Expected inlined-at fields to agree");
-
-    MIRBuilder.buildDbgLabel(DI.getLabel());
-    return true;
-  }
   case Intrinsic::vaend:
     // No target I know of cares about va_end. Certainly no in-tree target
     // does. Simplest intrinsic ever!
@@ -3107,20 +3089,6 @@ bool IRTranslatorImpl::translateKnownIntrinsic(const 
CallInst &CI,
                                                 ListSize, Alignment));
     return true;
   }
-  case Intrinsic::dbg_assign:
-    // A dbg.assign is a dbg.value with more information about stack locations,
-    // typically produced during optimisation of variables with leaked
-    // addresses. We can treat it like a normal dbg_value intrinsic here; to
-    // benefit from the full analysis of stack/SSA locations, GlobalISel would
-    // need to register for and use the AssignmentTrackingAnalysis pass.
-    [[fallthrough]];
-  case Intrinsic::dbg_value: {
-    // This form of DBG_VALUE is target-independent.
-    const DbgValueInst &DI = cast<DbgValueInst>(CI);
-    translateDbgValueRecord(DI.getValue(), DI.hasArgList(), DI.getVariable(),
-                       DI.getExpression(), DI.getDebugLoc(), MIRBuilder);
-    return true;
-  }
   case Intrinsic::uadd_with_overflow:
     return translateOverflowIntrinsic(CI, TargetOpcode::G_UADDO, MIRBuilder);
   case Intrinsic::sadd_with_overflow:
diff --git a/llvm/lib/CodeGen/IntrinsicLowering.cpp 
b/llvm/lib/CodeGen/IntrinsicLowering.cpp
index 7119d40662fcb..61fd62446cf18 100644
--- a/llvm/lib/CodeGen/IntrinsicLowering.cpp
+++ b/llvm/lib/CodeGen/IntrinsicLowering.cpp
@@ -326,10 +326,6 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
     break;
   }
 
-  case Intrinsic::dbg_declare:
-  case Intrinsic::dbg_label:
-    break;    // Simply strip out debugging intrinsics
-
   case Intrinsic::eh_typeid_for:
     // Return something different to eh_selector.
     CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1));
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 1cbe7c058f8ae..732b608362879 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -41,7 +41,6 @@
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InstIterator.h"
-#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Metadata.h"
@@ -9259,11 +9258,9 @@ static void FixupDebugInfoForOutlinedFunction(
     }
   };
 
-  // The location and scope of variable intrinsics and records still point to
+  // The location and scope of variable records still point to
   // the parent function of the target region. Update them.
   for (Instruction &I : instructions(Func)) {
-    assert(!isa<llvm::DbgVariableIntrinsic>(&I) &&
-           "Unexpected debug intrinsic");
     for (DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange())) {
       UpdateDebugRecord(&DVR);
       MoveDebugRecordToCorrectBlock(&DVR);
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp
index 4c4c460758f55..0c74f8c6749d2 100644
--- a/llvm/lib/IR/IntrinsicInst.cpp
+++ b/llvm/lib/IR/IntrinsicInst.cpp
@@ -161,12 +161,6 @@ void DbgVariableIntrinsic::replaceVariableLocationOp(Value 
*OldValue,
       0, MetadataAsValue::get(getContext(), DIArgList::get(getContext(), 
MDs)));
 }
 
-std::optional<uint64_t> DbgVariableIntrinsic::getFragmentSizeInBits() const {
-  if (auto Fragment = getExpression()->getFragmentInfo())
-    return Fragment->SizeInBits;
-  return getVariable()->getSizeInBits();
-}
-
 Value *DbgAssignIntrinsic::getAddress() const {
   auto *MD = getRawAddress();
   if (auto *V = dyn_cast<ValueAsMetadata>(MD))
@@ -177,20 +171,11 @@ Value *DbgAssignIntrinsic::getAddress() const {
   return nullptr;
 }
 
-void DbgAssignIntrinsic::setAssignId(DIAssignID *New) {
-  setOperand(OpAssignID, MetadataAsValue::get(getContext(), New));
-}
-
 void DbgAssignIntrinsic::setAddress(Value *V) {
   setOperand(OpAddress,
              MetadataAsValue::get(getContext(), ValueAsMetadata::get(V)));
 }
 
-void DbgAssignIntrinsic::setValue(Value *V) {
-  setOperand(OpValue,
-             MetadataAsValue::get(getContext(), ValueAsMetadata::get(V)));
-}
-
 ConstantInt *InstrProfCntrInstBase::getNumCounters() const {
   if (InstrProfValueProfileInst::classof(this))
     llvm_unreachable("InstrProfValueProfileInst does not have counters!");
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index ed7c68b24df1b..e61be072e8c09 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -450,7 +450,6 @@ class Verifier : public InstVisitor<Verifier>, 
VerifierSupport {
   void visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call);
   void visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI);
   void visitVPIntrinsic(VPIntrinsic &VPI);
-  void visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI);
   void visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI);
   void visitAtomicRMWInst(AtomicRMWInst &RMWI);
   void visitFenceInst(FenceInst &FI);
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp 
b/llvm/lib/Target/X86/X86FastISel.cpp
index f81e2d9fd3536..3deaeda621998 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -2932,21 +2932,6 @@ bool X86FastISel::fastLowerIntrinsicCall(const 
IntrinsicInst *II) {
     if (!X86FastEmitStore(PtrTy, Op1, AM)) return false;
     return true;
   }
-  case Intrinsic::dbg_declare: {
-    const DbgDeclareInst *DI = cast<DbgDeclareInst>(II);
-    X86AddressMode AM;
-    assert(DI->getAddress() && "Null address should be checked earlier!");
-    if (!X86SelectAddress(DI->getAddress(), AM))
-      return false;
-    const MCInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE);
-    assert(DI->getVariable()->isValidLocationForIntrinsic(MIMD.getDL()) &&
-           "Expected inlined-at fields to agree");
-    addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II), AM)
-        .addImm(0)
-        .addMetadata(DI->getVariable())
-        .addMetadata(DI->getExpression());
-    return true;
-  }
   case Intrinsic::trap: {
     BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(X86::TRAP));
     return true;
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp 
b/llvm/lib/Transforms/Scalar/ADCE.cpp
index 576bd1ec51cce..2e71d08068782 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/lib/Transforms/Scalar/ADCE.cpp
@@ -39,7 +39,6 @@
 #include "llvm/IR/InstIterator.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
-#include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/PassManager.h"
 #include "llvm/IR/Use.h"
 #include "llvm/IR/Value.h"
@@ -417,32 +416,6 @@ ADCEChanged 
AggressiveDeadCodeElimination::removeDeadInstructions() {
   // Updates control and dataflow around dead blocks
   Changed.ChangedControlFlow = updateDeadRegions();
 
-  LLVM_DEBUG({
-    for (Instruction &I : instructions(F)) {
-      // Check if the instruction is alive.
-      if (isLive(&I))
-        continue;
-
-      if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) {
-        // Check if the scope of this variable location is alive.
-        if (AliveScopes.count(DII->getDebugLoc()->getScope()))
-          continue;
-
-        // If intrinsic is pointing at a live SSA value, there may be an
-        // earlier optimization bug: if we know the location of the variable,
-        // why isn't the scope of the location alive?
-        for (Value *V : DII->location_ops()) {
-          if (Instruction *II = dyn_cast<Instruction>(V)) {
-            if (isLive(II)) {
-              dbgs() << "Dropping debug info for " << *DII << "\n";
-              break;
-            }
-          }
-        }
-      }
-    }
-  });
-
   // The inverse of the live set is the dead set.  These are those instructions
   // that have no side effects and do not influence the control flow or return
   // value of the function, and may therefore be deleted safely.
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp 
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 315dab206c014..1266fd0708bfe 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -778,10 +778,6 @@ static bool isNoopIntrinsic(Instruction *I) {
     case Intrinsic::launder_invariant_group:
     case Intrinsic::assume:
       return true;
-    case Intrinsic::dbg_declare:
-    case Intrinsic::dbg_label:
-    case Intrinsic::dbg_value:
-      llvm_unreachable("Intrinsic should not be modeled in MemorySSA");
     default:
       return false;
     }
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp 
b/llvm/lib/Transforms/Scalar/GVN.cpp
index d1df9bf21c875..0cd0902ac2f00 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2761,8 +2761,6 @@ std::optional<GVNPassImpl::ReachingMemVal> 
GVNPassImpl::accessMayModifyLocation(
   }
 
   if (auto *II = dyn_cast<IntrinsicInst>(ClobberI)) {
-    if (isa<DbgInfoIntrinsic>(II))
-      return std::nullopt;
     if (II->getIntrinsicID() == Intrinsic::lifetime_start) {
       MemoryLocation IIObjLoc = MemoryLocation::getForArgument(II, 0, TLI);
       if (AA.isMustAlias(IIObjLoc, Loc))
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp 
b/llvm/lib/Transforms/Scalar/SROA.cpp
index 037b461649a76..24b8937af0df9 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -5556,10 +5556,7 @@ static FixedVectorType 
*tryCanonicalizeStructToVector(StructType *STy,
       return true;
 
     User *Usr = U->getUser();
-    if (isa<LifetimeIntrinsic>(Usr) || isa<DbgInfoIntrinsic>(Usr))
-      return true;
-
-    return isa<MemIntrinsic>(Usr);
+    return isa<LifetimeIntrinsic, MemIntrinsic>(Usr);
   };
 
   for (const Slice &S : P)
diff --git a/llvm/lib/Transforms/Utils/Local.cpp 
b/llvm/lib/Transforms/Utils/Local.cpp
index 0511064a04d94..e6c8de5e4b6cc 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -420,12 +420,6 @@ bool llvm::wouldInstructionBeTriviallyDead(const 
Instruction *I,
   if (I->isEHPad())
     return false;
 
-  if (const DbgLabelInst *DLI = dyn_cast<DbgLabelInst>(I)) {
-    if (DLI->getLabel())
-      return false;
-    return true;
-  }
-
   if (auto *CB = dyn_cast<CallBase>(I))
     if (isRemovableAlloc(CB, TLI))
       return true;
@@ -1817,12 +1811,9 @@ void 
llvm::ConvertDebugDeclareToDebugValue(DbgVariableRecord *DVR, PHINode *APN,
 bool llvm::LowerDbgDeclare(Function &F) {
   bool Changed = false;
   DIBuilder DIB(*F.getParent(), /*AllowUnresolved*/ false);
-  SmallVector<DbgDeclareInst *, 4> Dbgs;
   SmallVector<DbgVariableRecord *> DVRs;
   for (auto &FI : F) {
     for (Instruction &BI : FI) {
-      if (auto *DDI = dyn_cast<DbgDeclareInst>(&BI))
-        Dbgs.push_back(DDI);
       for (DbgVariableRecord &DVR : filterDbgVars(BI.getDbgRecordRange())) {
         if (DVR.getType() == DbgVariableRecord::LocationType::Declare)
           DVRs.push_back(&DVR);
@@ -1830,7 +1821,7 @@ bool llvm::LowerDbgDeclare(Function &F) {
     }
   }
 
-  if (Dbgs.empty() && DVRs.empty())
+  if (DVRs.empty())
     return Changed;
 
   auto LowerOne = [&](DbgVariableRecord *DDI) {
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 552acc59d6b10..47ba50dbfa080 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -5672,19 +5672,8 @@ bool SimplifyCFGOpt::simplifyResume(ResumeInst *RI, 
IRBuilder<> &Builder) {
 static bool isCleanupBlockEmpty(iterator_range<BasicBlock::iterator> R) {
   for (Instruction &I : R) {
     auto *II = dyn_cast<IntrinsicInst>(&I);
-    if (!II)
+    if (!II || II->getIntrinsicID() != Intrinsic::lifetime_end)
       return false;
-
-    Intrinsic::ID IntrinsicID = II->getIntrinsicID();
-    switch (IntrinsicID) {
-    case Intrinsic::dbg_declare:
-    case Intrinsic::dbg_value:
-    case Intrinsic::dbg_label:
-    case Intrinsic::lifetime_end:
-      break;
-    default:
-      return false;
-    }
   }
   return true;
 }
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp 
b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
index c0d0163dab5fb..56899e186e044 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceMetadata.cpp
@@ -15,7 +15,7 @@
 #include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/IR/InstIterator.h"
-#include "llvm/IR/IntrinsicInst.h"
+#include "llvm/Support/CommandLine.h"
 
 using namespace llvm;
 
@@ -26,10 +26,6 @@ static cl::opt<bool> AggressiveMetadataReduction(
     cl::desc("Reduce named metadata without taking its type into account"),
     cl::cat(LLVMReduceOptions));
 
-static bool shouldKeepDebugIntrinsicMetadata(Instruction &I, MDNode &MD) {
-  return isa<DILocation>(MD) && isa<DbgInfoIntrinsic>(I);
-}
-
 static bool shouldKeepDebugNamedMetadata(NamedMDNode &MD) {
   return MD.getName() == "llvm.dbg.cu" && MD.getNumOperands() != 0;
 }
@@ -115,7 +111,7 @@ void llvm::reduceMetadataDeltaPass(Oracle &O, 
ReducerWorkItem &WorkItem) {
       SmallVector<std::pair<unsigned, MDNode *>> MDs;
       I.getAllMetadata(MDs);
       for (std::pair<unsigned, MDNode *> &MD : MDs) {
-        if (!shouldKeepDebugIntrinsicMetadata(I, *MD.second) && 
!O.shouldKeep())
+        if (!O.shouldKeep())
           I.setMetadata(MD.first, nullptr);
       }
     }
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp 
b/polly/lib/CodeGen/BlockGenerators.cpp
index f3edc183caf39..4cba4f366d820 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -213,12 +213,6 @@ Value *BlockGenerator::getNewValue(ScopStmt &Stmt, Value 
*Old, ValueMapT &BBMap,
 
 void BlockGenerator::copyInstScalar(ScopStmt &Stmt, Instruction *Inst,
                                     ValueMapT &BBMap, LoopToScevMapT &LTS) {
-  // We do not generate debug intrinsics as we did not investigate how to
-  // copy them correctly. At the current state, they just crash the code
-  // generation as the meta-data operands are not correctly copied.
-  if (isa<DbgInfoIntrinsic>(Inst))
-    return;
-
   Instruction *NewInst = Inst->clone();
 
   // Replace old operands with the new ones.
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 20473c231341f..8769b65a0f5d9 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -627,9 +627,6 @@ bool polly::isIgnoredIntrinsic(const Value *V) {
     case llvm::Intrinsic::annotation:
     case llvm::Intrinsic::donothing:
     case llvm::Intrinsic::assume:
-    // Some debug info intrinsics are supported/ignored.
-    case llvm::Intrinsic::dbg_value:
-    case llvm::Intrinsic::dbg_declare:
       return true;
     default:
       break;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to