@@ -119,26 +119,30 @@ Module::~Module() {
119
119
}
120
120
121
121
void Module::removeDebugIntrinsicDeclarations () {
122
- auto *DeclareIntrinsicFn =
123
- Intrinsic::getOrInsertDeclaration (this , Intrinsic::dbg_declare);
124
- assert ((!isMaterialized () || DeclareIntrinsicFn->hasZeroLiveUses ()) &&
125
- " Debug declare intrinsic should have had uses removed." );
126
- DeclareIntrinsicFn->eraseFromParent ();
127
- auto *ValueIntrinsicFn =
128
- Intrinsic::getOrInsertDeclaration (this , Intrinsic::dbg_value);
129
- assert ((!isMaterialized () || ValueIntrinsicFn->hasZeroLiveUses ()) &&
130
- " Debug value intrinsic should have had uses removed." );
131
- ValueIntrinsicFn->eraseFromParent ();
132
- auto *AssignIntrinsicFn =
133
- Intrinsic::getOrInsertDeclaration (this , Intrinsic::dbg_assign);
134
- assert ((!isMaterialized () || AssignIntrinsicFn->hasZeroLiveUses ()) &&
135
- " Debug assign intrinsic should have had uses removed." );
136
- AssignIntrinsicFn->eraseFromParent ();
137
- auto *LabelntrinsicFn =
138
- Intrinsic::getOrInsertDeclaration (this , Intrinsic::dbg_label);
139
- assert ((!isMaterialized () || LabelntrinsicFn->hasZeroLiveUses ()) &&
140
- " Debug label intrinsic should have had uses removed." );
141
- LabelntrinsicFn->eraseFromParent ();
122
+ if (auto *DeclareIntrinsicFn =
123
+ Intrinsic::getDeclarationIfExists (this , Intrinsic::dbg_declare)) {
124
+ assert ((!isMaterialized () || DeclareIntrinsicFn->hasZeroLiveUses ()) &&
125
+ " Debug declare intrinsic should have had uses removed." );
126
+ DeclareIntrinsicFn->eraseFromParent ();
127
+ }
128
+ if (auto *ValueIntrinsicFn =
129
+ Intrinsic::getDeclarationIfExists (this , Intrinsic::dbg_value)) {
130
+ assert ((!isMaterialized () || ValueIntrinsicFn->hasZeroLiveUses ()) &&
131
+ " Debug value intrinsic should have had uses removed." );
132
+ ValueIntrinsicFn->eraseFromParent ();
133
+ }
134
+ if (auto *AssignIntrinsicFn =
135
+ Intrinsic::getDeclarationIfExists (this , Intrinsic::dbg_assign)) {
136
+ assert ((!isMaterialized () || AssignIntrinsicFn->hasZeroLiveUses ()) &&
137
+ " Debug assign intrinsic should have had uses removed." );
138
+ AssignIntrinsicFn->eraseFromParent ();
139
+ }
140
+ if (auto *LabelntrinsicFn =
141
+ Intrinsic::getDeclarationIfExists (this , Intrinsic::dbg_label)) {
142
+ assert ((!isMaterialized () || LabelntrinsicFn->hasZeroLiveUses ()) &&
143
+ " Debug label intrinsic should have had uses removed." );
144
+ LabelntrinsicFn->eraseFromParent ();
145
+ }
142
146
}
143
147
144
148
std::unique_ptr<RandomNumberGenerator>
0 commit comments