Skip to content

Commit a7483b1

Browse files
bcardosolopeslanza
authored andcommitted
[CIR][CIRGen][NFC] Exceptions: sink invoke logic closer to call emission
1 parent 48b60d6 commit a7483b1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

clang/lib/CIR/CodeGen/CIRGenCall.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,19 @@ static mlir::cir::CIRCallOpInterface
446446
buildCallLikeOp(CIRGenFunction &CGF, mlir::Location callLoc,
447447
mlir::cir::FuncType indirectFuncTy, mlir::Value indirectFuncVal,
448448
mlir::cir::FuncOp directFuncOp,
449-
SmallVectorImpl<mlir::Value> &CIRCallArgs,
450-
mlir::Operation *InvokeDest, mlir::cir::CallingConv callingConv,
449+
SmallVectorImpl<mlir::Value> &CIRCallArgs, bool isInvoke,
450+
mlir::cir::CallingConv callingConv,
451451
mlir::cir::ExtraFuncAttributesAttr extraFnAttrs) {
452452
auto &builder = CGF.getBuilder();
453453

454-
if (InvokeDest) {
454+
if (isInvoke) {
455455
// This call can throw, few options:
456456
// - If this call does not have an associated cir.try, use the
457457
// one provided by InvokeDest,
458458
// - User written try/catch clauses require calls to handle
459459
// exceptions under cir.try.
460-
auto tryOp = dyn_cast_if_present<mlir::cir::TryOp>(InvokeDest);
460+
auto *invokeDest = CGF.getInvokeDest();
461+
auto tryOp = dyn_cast_if_present<mlir::cir::TryOp>(invokeDest);
461462
mlir::OpBuilder::InsertPoint ip = builder.saveInsertionPoint();
462463
bool changeInsertion = tryOp && tryOp.getSynthetic();
463464
if (changeInsertion) {
@@ -730,7 +731,8 @@ RValue CIRGenFunction::buildCall(const CIRGenFunctionInfo &CallInfo,
730731
noThrowAttr.getMnemonic()))
731732
CannotThrow = true;
732733
}
733-
auto InvokeDest = CannotThrow ? nullptr : getInvokeDest();
734+
// mlir::Operation *InvokeDest = CannotThrow ? nullptr : getInvokeDest();
735+
bool isInvoke = CannotThrow ? false : isInvokeDest();
734736

735737
// TODO: UnusedReturnSizePtr
736738
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl))
@@ -772,7 +774,7 @@ RValue CIRGenFunction::buildCall(const CIRGenFunctionInfo &CallInfo,
772774

773775
mlir::cir::CIRCallOpInterface callLikeOp = buildCallLikeOp(
774776
*this, callLoc, indirectFuncTy, indirectFuncVal, directFuncOp,
775-
CIRCallArgs, InvokeDest, callingConv, extraFnAttrs);
777+
CIRCallArgs, isInvoke, callingConv, extraFnAttrs);
776778

777779
if (E)
778780
callLikeOp->setAttr(

0 commit comments

Comments
 (0)