Skip to content

Commit e40c920

Browse files
committed
Address code review comments
1 parent 71b1af8 commit e40c920

File tree

4 files changed

+5
-75
lines changed

4 files changed

+5
-75
lines changed

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,9 @@ struct MissingFeatures {
374374

375375
// Future CIR attributes
376376
static bool optInfoAttr() { return false; }
377+
378+
// Maybe only needed for Windows exception handling
379+
static bool currentFuncletPad() { return false; }
377380
};
378381

379382
} // namespace cir

clang/lib/CIR/CodeGen/CIRGenException.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ void CIRGenFunction::exitCXXTryStmt(const CXXTryStmt &s, bool isFnTryBlock) {
419419
RunCleanupsScope catchScope(*this);
420420

421421
// Initialize the catch variable and set up the cleanups.
422-
SaveAndRestore restoreCurrentFuncletPad(currentFuncletPad);
422+
assert(!cir::MissingFeatures::currentFuncletPad());
423423
cgm.getCXXABI().emitBeginCatch(*this, catchStmt);
424424

425425
// Emit the PGO counter increment.

clang/lib/CIR/CodeGen/CIRGenFunction.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,6 @@ class CIRGenFunction : public CIRGenTypeCache {
12311231
};
12321232

12331233
LexicalScope *curLexScope = nullptr;
1234-
mlir::Operation *currentFuncletPad = nullptr;
12351234

12361235
typedef void Destroyer(CIRGenFunction &cgf, Address addr, QualType ty);
12371236

clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,56 +2321,6 @@ static mlir::Value callBeginCatch(CIRGenFunction &cgf, mlir::Type paramTy,
23212321
return catchParam.getParam();
23222322
}
23232323

2324-
/// A "special initializer" callback for initializing a catch
2325-
/// parameter during catch initialization.
2326-
static void initCatchParam(CIRGenFunction &cgf, const VarDecl &catchParam,
2327-
Address paramAddr, SourceLocation loc) {
2328-
CanQualType catchType =
2329-
cgf.cgm.getASTContext().getCanonicalType(catchParam.getType());
2330-
// If we're catching by reference, we can just cast the object
2331-
// pointer to the appropriate pointer.
2332-
if (isa<ReferenceType>(catchType)) {
2333-
cgf.cgm.errorNYI(loc, "initCatchParam: ReferenceType");
2334-
return;
2335-
}
2336-
2337-
// Scalars and complexes.
2338-
cir::TypeEvaluationKind tek = cgf.getEvaluationKind(catchType);
2339-
if (tek != cir::TEK_Aggregate) {
2340-
// Notes for LLVM lowering:
2341-
// If the catch type is a pointer type, __cxa_begin_catch returns
2342-
// the pointer by value.
2343-
if (catchType->hasPointerRepresentation()) {
2344-
cgf.cgm.errorNYI(loc, "initCatchParam: hasPointerRepresentation");
2345-
return;
2346-
}
2347-
2348-
mlir::Type cirCatchTy = cgf.convertTypeForMem(catchType);
2349-
mlir::Value catchParam =
2350-
callBeginCatch(cgf, cgf.getBuilder().getPointerTo(cirCatchTy), false);
2351-
LValue srcLV = cgf.makeNaturalAlignAddrLValue(catchParam, catchType);
2352-
LValue destLV = cgf.makeAddrLValue(paramAddr, catchType);
2353-
switch (tek) {
2354-
case cir::TEK_Complex: {
2355-
cgf.cgm.errorNYI(loc, "initCatchParam: cir::TEK_Complex");
2356-
return;
2357-
}
2358-
case cir::TEK_Scalar: {
2359-
auto exnLoad = cgf.emitLoadOfScalar(srcLV, loc);
2360-
cgf.emitStoreOfScalar(exnLoad, destLV, /*isInit=*/true);
2361-
return;
2362-
}
2363-
case cir::TEK_Aggregate:
2364-
llvm_unreachable("evaluation kind filtered out!");
2365-
}
2366-
2367-
// Otherwise, it returns a pointer into the exception object.
2368-
llvm_unreachable("bad evaluation kind");
2369-
}
2370-
2371-
cgf.cgm.errorNYI(loc, "initCatchParam: cir::TEK_Aggregate");
2372-
}
2373-
23742324
/// Begins a catch statement by initializing the catch variable and
23752325
/// calling __cxa_begin_catch.
23762326
void CIRGenItaniumCXXABI::emitBeginCatch(CIRGenFunction &cgf,
@@ -2405,27 +2355,5 @@ void CIRGenItaniumCXXABI::emitBeginCatch(CIRGenFunction &cgf,
24052355
return;
24062356
}
24072357

2408-
auto getCatchParamAllocaIP = [&]() {
2409-
auto currIns = cgf.getBuilder().saveInsertionPoint();
2410-
mlir::Operation *currParent = currIns.getBlock()->getParentOp();
2411-
2412-
mlir::Block *insertBlock = nullptr;
2413-
if (auto scopeOp = currParent->getParentOfType<cir::ScopeOp>()) {
2414-
insertBlock = &scopeOp.getScopeRegion().getBlocks().back();
2415-
} else if (auto fnOp = currParent->getParentOfType<cir::FuncOp>()) {
2416-
insertBlock = &fnOp.getRegion().getBlocks().back();
2417-
} else {
2418-
llvm_unreachable("unknown outermost scope-like parent");
2419-
}
2420-
return cgf.getBuilder().getBestAllocaInsertPoint(insertBlock);
2421-
};
2422-
2423-
// Emit the local. Make sure the alloca's superseed the current scope, since
2424-
// these are going to be consumed by `cir.catch`, which is not within the
2425-
// current scope.
2426-
CIRGenFunction::AutoVarEmission var =
2427-
cgf.emitAutoVarAlloca(*catchParam, getCatchParamAllocaIP());
2428-
initCatchParam(cgf, *catchParam, var.getObjectAddress(cgf),
2429-
catchStmt->getBeginLoc());
2430-
cgf.emitAutoVarCleanups(var);
2358+
cgf.cgm.errorNYI("emitBeginCatch: catch with exception decl");
24312359
}

0 commit comments

Comments
 (0)