31 "__gxx_personality_sj0",
nullptr};
33 "__gxx_personality_seh0",
nullptr};
35 "objc_exception_throw"};
37 "__gnu_objc_personality_sj0",
"objc_exception_throw"};
39 "__gnu_objc_personality_seh0",
"objc_exception_throw"};
41 "__gnustep_objcxx_personality_v0",
nullptr};
43 "__gnustep_objc_personality_v0",
nullptr};
47 "__C_specific_handler",
nullptr};
49 "__CxxFrameHandler3",
nullptr};
51 "__gxx_wasm_personality_v0",
nullptr};
59 const llvm::Triple &triple = target.
getTriple();
60 if (triple.isWindowsMSVCEnvironment())
74 const llvm::Triple &triple = target.
getTriple();
75 if (triple.isWindowsMSVCEnvironment())
97 llvm_unreachable(
"bad runtime kind");
102 const llvm::Triple &triple = target.
getTriple();
103 if (triple.isWindowsMSVCEnvironment())
105 if (triple.isOSAIX())
123 if (target.
getTriple().isWindowsMSVCEnvironment())
149 llvm_unreachable(
"bad runtime kind");
153 return triple.getArch() == llvm::Triple::x86
183 return get(cgf.
cgm, dyn_cast_or_null<FunctionDecl>(fg));
188 if (
cgm.getLangOpts().OpenMPIsTargetDevice &&
189 (triple.isNVPTX() || triple.isAMDGCN())) {
190 cgm.errorNYI(
"emitCXXThrowExpr OpenMP with NVPTX or AMDGCN Triples");
195 QualType throwType = subExpr->getType();
197 cgm.errorNYI(
"emitCXXThrowExpr ObjCObjectPointerType");
201 cgm.getCXXABI().emitThrow(*
this, e);
205 cgm.getCXXABI().emitRethrow(*
this,
true);
234 if (
s.getTryBlock()->body_empty())
235 return mlir::LogicalResult::success();
237 mlir::Location loc =
getLoc(
s.getSourceRange());
240 mlir::OpBuilder::InsertPoint scopeIP;
241 cir::ScopeOp::create(
243 [&](mlir::OpBuilder &
b, mlir::Location loc) {
244 scopeIP = builder.saveInsertionPoint();
247 mlir::OpBuilder::InsertionGuard guard(builder);
248 builder.restoreInsertionPoint(scopeIP);
250 cir::YieldOp::create(builder, loc);
259 const bool isTargetDevice =
260 (
cgm.getLangOpts().OpenMPIsTargetDevice && (t.isNVPTX() || t.isAMDGCN()));
261 if (isTargetDevice) {
263 "emitCXXTryStmtUnderScope: OpenMP target region offloaded to GPU");
264 return mlir::success();
267 unsigned numHandlers =
s.getNumHandlers();
268 mlir::Location tryLoc =
getLoc(
s.getBeginLoc());
269 mlir::OpBuilder::InsertPoint beginInsertTryBody;
271 bool hasCatchAll =
false;
272 for (
unsigned i = 0; i != numHandlers; ++i) {
273 hasCatchAll |=
s.getHandler(i)->getExceptionDecl() ==
nullptr;
282 auto tryOp = cir::TryOp::create(
285 [&](mlir::OpBuilder &
b, mlir::Location loc) {
286 beginInsertTryBody = builder.saveInsertionPoint();
289 [&](mlir::OpBuilder &
b, mlir::Location loc,
290 mlir::OperationState &result) {
291 mlir::OpBuilder::InsertionGuard guard(
b);
295 unsigned numRegionsToCreate =
296 hasCatchAll ? numHandlers : numHandlers + 1;
298 for (
unsigned i = 0; i != numRegionsToCreate; ++i) {
299 mlir::Region *region = result.addRegion();
300 builder.createBlock(region);
306 mlir::Location loc = tryOp.getLoc();
307 mlir::OpBuilder::InsertionGuard guard(builder);
308 builder.restoreInsertionPoint(beginInsertTryBody);
310 builder.getInsertionBlock()};
319 mlir::OpBuilder::InsertionGuard guard(builder);
321 builder.getInsertionBlock()};
322 if (
emitStmt(
s.getTryBlock(),
true).failed())
323 return mlir::failure();
330 return mlir::success();
335 unsigned numHandlers =
s.getNumHandlers();
337 for (
unsigned i = 0; i != numHandlers; ++i) {
340 cgm.errorNYI(
"enterCXXTryStmt: CatchStmt with ExceptionDecl");
345 mlir::Region *handler = &tryOp.getHandlerRegions()[i];
346 catchScope->
setHandler(i,
cgm.getCXXABI().getCatchAllTypeInfo(), handler);
351 cgm.errorNYI(
"enterCXXTryStmt: EHAsynch");
358 unsigned numHandlers =
s.getNumHandlers();
370 for (mlir::Region &handlerRegion : tryOp.getHandlerRegions()) {
371 if (handlerRegion.empty())
374 for (mlir::Block &
b : handlerRegion.getBlocks())
375 eraseBlocks.push_back(&
b);
378 for (mlir::Block *
b : eraseBlocks)
381 tryOp.setHandlerTypesAttr({});
385 cgm.errorNYI(
"exitCXXTryStmt: Required catch");
static const EHPersonality & getCXXPersonality(const TargetInfo &target, const CodeGenOptions &cgOpts)
static const EHPersonality & getCPersonality(const TargetInfo &target, const CodeGenOptions &cgOpts)
static const EHPersonality & getObjCPersonality(const TargetInfo &target, const LangOptions &langOpts, const CodeGenOptions &cgOpts)
static const EHPersonality & getObjCXXPersonality(const TargetInfo &target, const LangOptions &langOpts, const CodeGenOptions &cgOpts)
Determines the personality function to use when both C++ and Objective-C exceptions are being caught.
static const EHPersonality & getSEHPersonalityMSVC(const llvm::Triple &triple)
__device__ __2f16 float __ockl_bool s
Address withElementType(CIRGenBuilderTy &builder, mlir::Type ElemTy) const
Return address with different element type, a bitcast pointer, and the same alignment.
const clang::LangOptions & getLangOpts() const
void enterCXXTryStmt(const CXXTryStmt &s, cir::TryOp tryOp, bool isFnTryBlock=false)
void exitCXXTryStmt(const CXXTryStmt &s, bool isFnTryBlock=false)
const TargetInfo & getTarget() const
void emitAnyExprToExn(const Expr *e, Address addr)
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
void emitAnyExprToMem(const Expr *e, Address location, Qualifiers quals, bool isInitializer)
Emits the code necessary to evaluate an arbitrary expression into the given memory location.
mlir::LogicalResult emitCXXTryStmtUnderScope(const clang::CXXTryStmt &s)
EHScopeStack ehStack
Tracks function scope overall cleanup handling.
mlir::Type convertTypeForMem(QualType t)
const clang::Decl * curCodeDecl
This is the inner-most code context, which includes blocks.
mlir::LogicalResult emitCXXTryStmt(const clang::CXXTryStmt &s)
void emitCXXThrowExpr(const CXXThrowExpr *e)
LexicalScope * curLexScope
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
This class organizes the cross-function state that is used while generating CIR code.
const clang::TargetInfo & getTarget() const
const clang::CodeGenOptions & getCodeGenOpts() const
const clang::LangOptions & getLangOpts() const
A scope which attempts to handle some, possibly all, types of exceptions.
void setHandler(unsigned i, CatchTypeInfo type, mlir::Region *region)
unsigned getNumHandlers() const
void clearHandlerBlocks()
CXXCatchStmt - This represents a C++ catch block.
VarDecl * getExceptionDecl() const
A C++ throw-expression (C++ [except.throw]).
const Expr * getSubExpr() const
CXXTryStmt - A C++ try block, including all handlers.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
bool hasDWARFExceptions() const
bool hasWasmExceptions() const
bool hasSjLjExceptions() const
bool hasSEHExceptions() const
This represents one expression.
Represents a function declaration or definition.
bool usesSEHTry() const
Indicates the function uses __try.
const Decl * getDecl() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
const VersionTuple & getVersion() const
@ MacOSX
'macosx' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the non-fragile AB...
@ FragileMacOSX
'macosx-fragile' is the Apple-provided NeXT-derived runtime on Mac OS X platforms that use the fragil...
@ GNUstep
'gnustep' is the modern non-fragile GNUstep runtime.
@ ObjFW
'objfw' is the Objective-C runtime included in ObjFW
@ iOS
'ios' is the Apple-provided NeXT-derived runtime on iOS or the iOS simulator; it is always non-fragil...
@ GCC
'gcc' is the Objective-C runtime shipped with GCC, implementing a fragile Objective-C ABI
@ WatchOS
'watchos' is a variant of iOS for Apple's watchOS.
A (possibly-)qualified type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool isObjCObjectPointerType() const
The JSON file list parser is used to communicate input to InstallAPI.
U cast(CodeGen::Address addr)
static bool ehCleanupScope()
Represents a scope, including function bodies, compound statements, and the substatements of if/while...
void setAsTry(cir::TryOp op)
The exceptions personality for a function.
static const EHPersonality XL_CPlusPlus
static const EHPersonality GNU_ObjC_SJLJ
static const EHPersonality ZOS_CPlusPlus
static const EHPersonality GNUstep_ObjC
static const EHPersonality MSVC_CxxFrameHandler3
static const EHPersonality MSVC_C_specific_handler
static const EHPersonality GNU_CPlusPlus_SEH
static const EHPersonality GNU_ObjC
static const EHPersonality GNU_CPlusPlus_SJLJ
static const EHPersonality GNU_C_SJLJ
static const EHPersonality GNU_C
static const EHPersonality NeXT_ObjC
static const EHPersonality & get(CIRGenModule &cgm, const clang::FunctionDecl *fd)
static const EHPersonality GNU_CPlusPlus
static const EHPersonality GNU_ObjCXX
static const EHPersonality GNU_C_SEH
static const EHPersonality MSVC_except_handler
static const EHPersonality GNU_ObjC_SEH
static const EHPersonality GNU_Wasm_CPlusPlus