@@ -153,7 +153,7 @@ size_t DwarfEHPrepare::pruneUnreachableResumes(
153
153
BasicBlock *BB = RI->getParent ();
154
154
new UnreachableInst (Ctx, RI);
155
155
RI->eraseFromParent ();
156
- simplifyCFG (BB, *TTI, RequireAndPreserveDomTree ? DTU : nullptr );
156
+ simplifyCFG (BB, *TTI, DTU);
157
157
}
158
158
}
159
159
Resumes.resize (ResumesLeft);
@@ -242,33 +242,23 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() {
242
242
CI->setDoesNotReturn ();
243
243
new UnreachableInst (Ctx, UnwindBB);
244
244
245
- if (DTU && RequireAndPreserveDomTree )
245
+ if (DTU)
246
246
DTU->applyUpdates (Updates);
247
247
248
248
return true ;
249
249
}
250
250
251
251
bool DwarfEHPrepare::run () {
252
- assert (((OptLevel == CodeGenOpt::None || !RequireAndPreserveDomTree) ||
253
- (DTU &&
254
- DTU->getDomTree ().verify (DominatorTree::VerificationLevel::Full))) &&
255
- " Original domtree is invalid?" );
256
-
257
252
bool Changed = InsertUnwindResumeCalls ();
258
253
259
- assert (((OptLevel == CodeGenOpt::None || !RequireAndPreserveDomTree) ||
260
- (DTU &&
261
- DTU->getDomTree ().verify (DominatorTree::VerificationLevel::Full))) &&
262
- " Original domtree is invalid?" );
263
-
264
254
return Changed;
265
255
}
266
256
267
257
static bool prepareDwarfEH (CodeGenOpt::Level OptLevel,
268
258
FunctionCallee &RewindFunction, Function &F,
269
259
const TargetLowering &TLI, DominatorTree *DT,
270
260
const TargetTransformInfo *TTI) {
271
- DomTreeUpdater DTU (DT, DomTreeUpdater::UpdateStrategy::Eager );
261
+ DomTreeUpdater DTU (DT, DomTreeUpdater::UpdateStrategy::Lazy );
272
262
273
263
return DwarfEHPrepare (OptLevel, RewindFunction, F, TLI, DT ? &DTU : nullptr ,
274
264
TTI)
@@ -295,8 +285,11 @@ class DwarfEHPrepareLegacyPass : public FunctionPass {
295
285
const TargetLowering &TLI = *TM.getSubtargetImpl (F)->getTargetLowering ();
296
286
DominatorTree *DT = nullptr ;
297
287
const TargetTransformInfo *TTI = nullptr ;
288
+ if (auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
289
+ DT = &DTWP->getDomTree ();
298
290
if (OptLevel != CodeGenOpt::None) {
299
- DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree ();
291
+ if (!DT)
292
+ DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree ();
300
293
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI (F);
301
294
}
302
295
return prepareDwarfEH (OptLevel, RewindFunction, F, TLI, DT, TTI);
@@ -308,9 +301,8 @@ class DwarfEHPrepareLegacyPass : public FunctionPass {
308
301
if (OptLevel != CodeGenOpt::None) {
309
302
AU.addRequired <DominatorTreeWrapperPass>();
310
303
AU.addRequired <TargetTransformInfoWrapperPass>();
311
- if (RequireAndPreserveDomTree)
312
- AU.addPreserved <DominatorTreeWrapperPass>();
313
304
}
305
+ AU.addPreserved <DominatorTreeWrapperPass>();
314
306
}
315
307
316
308
StringRef getPassName () const override {
0 commit comments