diff options
author | Joseph Tremoulet <jotrem@microsoft.com> | 2015-08-23 00:26:33 +0000 |
---|---|---|
committer | Joseph Tremoulet <jotrem@microsoft.com> | 2015-08-23 00:26:33 +0000 |
commit | 8220bcc5700305452e823ad2d37d769f8f15a497 (patch) | |
tree | 3498781194fdabe5977d69f40bb8bb28514a6271 /llvm/lib/CodeGen | |
parent | 0732e16e690e251e92463d25b0de16c4a71a41b9 (diff) | |
download | bcm5719-llvm-8220bcc5700305452e823ad2d37d769f8f15a497.tar.gz bcm5719-llvm-8220bcc5700305452e823ad2d37d769f8f15a497.zip |
[WinEH] Require token linkage in EH pad/ret signatures
Summary:
WinEHPrepare is going to require that cleanuppad and catchpad produce values
of token type which are consumed by any cleanupret or catchret exiting the
pad. This change updates the signatures of those operators to require/enforce
that the type produced by the pads is token type and that the rets have an
appropriate argument.
The catchpad argument of a `CatchReturnInst` must be a `CatchPadInst` (and
similarly for `CleanupReturnInst`/`CleanupPadInst`). To accommodate that
restriction, this change adds a notion of an operator constraint to both
LLParser and BitcodeReader, allowing appropriate sentinels to be constructed
for forward references and appropriate error messages to be emitted for
illegal inputs.
Also add a verifier rule (noted in LangRef) that a catchpad with a catchpad
predecessor must have no other predecessors; this ensures that WinEHPrepare
will see the expected linear relationship between sibling catches on the
same try.
Lastly, remove some superfluous/vestigial casts from instruction operand
setters operating on BasicBlocks.
Reviewers: rnk, majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D12108
llvm-svn: 245797
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/WinEHPrepare.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index 68384f08b7c..3cc9c395c22 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -2956,8 +2956,7 @@ static const BasicBlock *getEHPadFromPredecessor(const BasicBlock *BB) { if (isa<CatchPadInst>(TI) || isa<CatchEndPadInst>(TI) || isa<TerminatePadInst>(TI)) return BB; - return cast<CleanupPadInst>(cast<CleanupReturnInst>(TI)->getReturnValue()) - ->getParent(); + return cast<CleanupReturnInst>(TI)->getCleanupPad()->getParent(); } static void calculateExplicitStateNumbers(WinEHFuncInfo &FuncInfo, @@ -3242,11 +3241,11 @@ bool WinEHPrepare::prepareExplicitEH(Function &F) { // The token consumed by a CatchReturnInst must match the funclet token. bool IsUnreachableCatchret = false; if (auto *CRI = dyn_cast<CatchReturnInst>(TI)) - IsUnreachableCatchret = CRI->getReturnValue() != CatchPad; + IsUnreachableCatchret = CRI->getCatchPad() != CatchPad; // The token consumed by a CleanupPadInst must match the funclet token. bool IsUnreachableCleanupret = false; if (auto *CRI = dyn_cast<CleanupReturnInst>(TI)) - IsUnreachableCleanupret = CRI->getReturnValue() != CleanupPad; + IsUnreachableCleanupret = CRI->getCleanupPad() != CleanupPad; if (IsUnreachableRet || IsUnreachableCatchret || IsUnreachableCleanupret) { new UnreachableInst(BB->getContext(), TI); TI->eraseFromParent(); |