Skip to content

Commit 94fdebc

Browse files
tkfvchuravy
authored andcommitted
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 (cherry picked from commit 8f6e49e)
1 parent 0b28ec6 commit 94fdebc

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
@@ -318,6 +318,11 @@ class DwarfEHPrepareLegacyPass : public FunctionPass {
318318
return prepareDwarfEH(OptLevel, RewindFunction, F, TLI, DT, TTI);
319319
}
320320

321+
bool doFinalization(Module &M) override {
322+
RewindFunction = nullptr;
323+
return false;
324+
}
325+
321326
void getAnalysisUsage(AnalysisUsage &AU) const override {
322327
AU.addRequired<TargetPassConfig>();
323328
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)