diff options
author | Nikita Popov <npopov@redhat.com> | 2025-06-24 14:50:14 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2025-06-24 15:37:27 +0200 |
commit | 68f09370f99f1c079827f1d1e2e5774d8d2c90e3 (patch) | |
tree | 57b7b25889904e0b7ec848feded799a44880b2fc /llvm/lib/IR/Module.cpp | |
parent | 75cf826849713c00829cdf657e330e24c1a2fd03 (diff) | |
download | llvm-68f09370f99f1c079827f1d1e2e5774d8d2c90e3.zip llvm-68f09370f99f1c079827f1d1e2e5774d8d2c90e3.tar.gz llvm-68f09370f99f1c079827f1d1e2e5774d8d2c90e3.tar.bz2 |
[Module] Use getDeclarationIfExists() (NFC)
Don't insert declarations in order to immediately remove them
again.
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> |