Skip to content

[Typed throws] Handle throw_addr in the same places as throw. #69654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/SIL/ApplySite.h
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ class FullApplySite : public ApplySite {
bool isIndirectErrorResultOperand(const Operand &op) const {
return isArgumentOperand(op)
&& (getCalleeArgIndex(op) >= getNumIndirectSILResults())
&& (getCalleeArgIndex(op) < getNumIndirectSILErrorResults());
&& (getCalleeArgIndex(op) < getNumIndirectSILResults() + getNumIndirectSILErrorResults());
}

static FullApplySite getFromOpaqueValue(void *p) { return FullApplySite(p); }
Expand Down
4 changes: 2 additions & 2 deletions include/swift/SIL/SILFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ class SILFunction
return std::find_if(begin(), end(),
[](const SILBasicBlock &BB) -> bool {
const TermInst *TI = BB.getTerminator();
return isa<ThrowInst>(TI);
return isa<ThrowInst>(TI) || isa<ThrowAddrInst>(TI);
});
}

Expand All @@ -1413,7 +1413,7 @@ class SILFunction
return std::find_if(begin(), end(),
[](const SILBasicBlock &BB) -> bool {
const TermInst *TI = BB.getTerminator();
return isa<ThrowInst>(TI);
return isa<ThrowInst>(TI) || isa<ThrowAddrInst>(TI);
});
}

Expand Down
3 changes: 2 additions & 1 deletion include/swift/SILOptimizer/Analysis/EpilogueARCAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class EpilogueARCContext {
return BB->getTerminator()->isFunctionExiting();

return BB->getTerminator()->isFunctionExiting() &&
BB->getTerminator()->getTermKind() != TermKind::ThrowInst;
BB->getTerminator()->getTermKind() != TermKind::ThrowInst &&
BB->getTerminator()->getTermKind() != TermKind::ThrowAddrInst;
}

/// Return true if this is a function exit block.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,8 @@ class ShortestPathAnalysis {

if (isa<ReturnInst>(BB.getTerminator()))
BBInfo->getDistances(0).DistToExit = Length;
else if (isa<ThrowInst>(BB.getTerminator()))
else if (isa<ThrowInst>(BB.getTerminator()) ||
isa<ThrowAddrInst>(BB.getTerminator()))
BBInfo->getDistances(0).DistToExit = Length + ColdBlockLength;
}
// Compute the distances for all loops in the function.
Expand Down
2 changes: 1 addition & 1 deletion lib/SIL/IR/SILInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ bool SILInstruction::isTriviallyDuplicatable() const {
if (MI->getMember().isForeign)
return false;
}
if (isa<ThrowInst>(this))
if (isa<ThrowInst>(this) || isa<ThrowAddrInst>(this))
return false;

// BeginAccess defines the access scope entry point. All associated EndAccess
Expand Down
3 changes: 2 additions & 1 deletion lib/SIL/Verifier/SILVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6265,7 +6265,8 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
return true;
else if (isa<ReturnInst>(StartBlock->getTerminator()))
return false;
else if (isa<ThrowInst>(StartBlock->getTerminator()))
else if (isa<ThrowInst>(StartBlock->getTerminator()) ||
isa<ThrowAddrInst>(StartBlock->getTerminator()))
return false;

// Recursively check all successors.
Expand Down
4 changes: 2 additions & 2 deletions lib/SILOptimizer/Transforms/ARCCodeMotion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ class RetainCodeMotionContext : public CodeMotionContext {
// end, this function is called many times.
//
// These terminator instructions block.
if (isa<ReturnInst>(II) || isa<ThrowInst>(II) || isa<UnwindInst>(II) ||
isa<UnreachableInst>(II))
if (isa<ReturnInst>(II) || isa<ThrowInst>(II) || isa<ThrowAddrInst>(II) ||
isa<UnwindInst>(II) || isa<UnreachableInst>(II))
return true;
// Identical RC root blocks code motion, we will be able to move this retain
// further once we move the blocking retain.
Expand Down
2 changes: 1 addition & 1 deletion lib/SILOptimizer/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ bool swift::canDuplicateLoopInstruction(SILLoop *L, SILInstruction *I) {
return true;
}

if (isa<ThrowInst>(I))
if (isa<ThrowInst>(I) || isa<ThrowAddrInst>(I))
return false;

// The entire access must be within the loop.
Expand Down