Skip to content

Commit

Permalink
[WinEH] Emit state stores before SEH scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
momo5502 committed Nov 17, 2024
1 parent 4f48a81 commit 6ede329
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions llvm/lib/Target/X86/X86WinEHState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,8 +604,18 @@ static int getSuccState(DenseMap<BasicBlock *, int> &InitialStates, Function &F,
return CommonState;
}

static bool isSehScopeBegin(const CallBase &Call) {
const Function *CF = Call.getCalledFunction();
return CF && CF->isIntrinsic() &&
CF->getIntrinsicID() == Intrinsic::seh_scope_begin;
}

bool WinEHStatePass::isStateStoreNeeded(EHPersonality Personality,
CallBase &Call) {
if (isSehScopeBegin(Call)) {
return true;
}

// If the function touches memory, it needs a state store.
if (isAsynchronousEHPersonality(Personality))
return !Call.doesNotAccessMemory();
Expand Down

0 comments on commit 6ede329

Please sign in to comment.