diff options
Diffstat (limited to 'llvm/lib/IR/Module.cpp')
-rw-r--r-- | llvm/lib/IR/Module.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 2d31481..70d3641 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -119,26 +119,30 @@ Module::~Module() { } void Module::removeDebugIntrinsicDeclarations() { - auto *DeclareIntrinsicFn = - Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_declare); - assert((!isMaterialized() || DeclareIntrinsicFn->hasZeroLiveUses()) && - "Debug declare intrinsic should have had uses removed."); - DeclareIntrinsicFn->eraseFromParent(); - auto *ValueIntrinsicFn = - Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_value); - assert((!isMaterialized() || ValueIntrinsicFn->hasZeroLiveUses()) && - "Debug value intrinsic should have had uses removed."); - ValueIntrinsicFn->eraseFromParent(); - auto *AssignIntrinsicFn = - Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_assign); - assert((!isMaterialized() || AssignIntrinsicFn->hasZeroLiveUses()) && - "Debug assign intrinsic should have had uses removed."); - AssignIntrinsicFn->eraseFromParent(); - auto *LabelntrinsicFn = - Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_label); - assert((!isMaterialized() || LabelntrinsicFn->hasZeroLiveUses()) && - "Debug label intrinsic should have had uses removed."); - LabelntrinsicFn->eraseFromParent(); + if (auto *DeclareIntrinsicFn = + Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_declare)) { + assert((!isMaterialized() || DeclareIntrinsicFn->hasZeroLiveUses()) && + "Debug declare intrinsic should have had uses removed."); + DeclareIntrinsicFn->eraseFromParent(); + } + if (auto *ValueIntrinsicFn = + Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_value)) { + assert((!isMaterialized() || ValueIntrinsicFn->hasZeroLiveUses()) && + "Debug value intrinsic should have had uses removed."); + ValueIntrinsicFn->eraseFromParent(); + } + if (auto *AssignIntrinsicFn = + Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_assign)) { + assert((!isMaterialized() || AssignIntrinsicFn->hasZeroLiveUses()) && + "Debug assign intrinsic should have had uses removed."); + AssignIntrinsicFn->eraseFromParent(); + } + if (auto *LabelntrinsicFn = + Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_label)) { + assert((!isMaterialized() || LabelntrinsicFn->hasZeroLiveUses()) && + "Debug label intrinsic should have had uses removed."); + LabelntrinsicFn->eraseFromParent(); + } } std::unique_ptr<RandomNumberGenerator> |