Skip to content

Commit 8f6e49e

Browse files
authored
Re-apply the fix on DwarfEHPrepare and add a test (#2)
* Ad -run-twice to dwarf-eh-prepare.ll * In DwarfEHPrepare, after all passes are run, RewindFunction may be a dangling pointer to a dead function. To make sure it's valid, doFinalization nullptrs RewindFunction just like the constructor and so it will be found on next run. llvm-svn: 217737 Co-authored-by: Yaron Keren <[email protected]> https://reviews.llvm.org/D110979
1 parent dc15204 commit 8f6e49e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/CodeGen/DwarfEHPrepare.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ class DwarfEHPrepareLegacyPass : public FunctionPass {
302302
return prepareDwarfEH(OptLevel, RewindFunction, F, TLI, DT, TTI);
303303
}
304304

305+
bool doFinalization(Module &M) override {
306+
RewindFunction = nullptr;
307+
return false;
308+
}
309+
305310
void getAnalysisUsage(AnalysisUsage &AU) const override {
306311
AU.addRequired<TargetPassConfig>();
307312
AU.addRequired<TargetTransformInfoWrapperPass>();

llvm/test/CodeGen/X86/dwarf-eh-prepare.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: opt -mtriple=x86_64-linux-gnu -dwarfehprepare -simplifycfg-require-and-preserve-domtree=1 < %s -S | FileCheck %s
1+
; RUN: opt -mtriple=x86_64-linux-gnu -dwarfehprepare -simplifycfg-require-and-preserve-domtree=1 -run-twice < %s -S | FileCheck %s
22

33
; Check basic functionality of IR-to-IR DWARF EH preparation. This should
44
; eliminate resumes. This pass requires a TargetMachine, so we put it under X86

0 commit comments

Comments
 (0)