31#include "mlir/IR/Builders.h"
32#include "mlir/IR/IRMapping.h"
33#include "mlir/IR/PatternMatch.h"
38#include "llvm/ADT/DenseMap.h"
39#include "llvm/ADT/SmallVector.h"
40#include "llvm/TargetParser/Triple.h"
46#define GEN_PASS_DEF_CIREHABILOWERING
47#include "clang/CIR/Dialect/Passes.h.inc"
58static cir::FuncOp getOrCreateRuntimeFuncDecl(mlir::ModuleOp mod,
61 cir::FuncType funcTy) {
62 if (
auto existing = mod.lookupSymbol<cir::FuncOp>(
name))
65 mlir::OpBuilder builder(mod.getContext());
66 builder.setInsertionPointToEnd(mod.getBody());
67 auto funcOp = cir::FuncOp::create(builder, loc,
name, funcTy);
68 funcOp.setLinkage(cir::GlobalLinkageKind::ExternalLinkage);
81 explicit EHABILowering(mlir::ModuleOp mod)
82 : mod(mod), ctx(mod.getContext()), builder(ctx) {}
83 virtual ~EHABILowering() =
default;
86 virtual mlir::LogicalResult
run() = 0;
90 mlir::MLIRContext *ctx;
91 mlir::OpBuilder builder;
105class ItaniumEHLowering :
public EHABILowering {
107 using EHABILowering::EHABILowering;
108 mlir::LogicalResult
run()
override;
113 using EhTokenMap = DenseMap<mlir::Value, std::pair<mlir::Value, mlir::Value>>;
115 cir::VoidType voidType;
116 cir::PointerType voidPtrType;
117 cir::PointerType u8PtrType;
118 cir::IntType u32Type;
122 cir::FuncOp personalityFunc;
123 cir::FuncOp beginCatchFunc;
124 cir::FuncOp endCatchFunc;
125 cir::FuncOp getExceptionPtrFunc;
126 cir::FuncOp clangCallTerminateFunc;
128 DenseMap<mlir::StringAttr, cir::FuncOp> catchCopyThunks;
130 constexpr const static ::llvm::StringLiteral kGxxPersonality =
131 "__gxx_personality_v0";
133 void ensureRuntimeDecls(mlir::Location loc);
134 void ensureClangCallTerminate(mlir::Location loc);
135 mlir::Block *buildTerminateBlock(cir::FuncOp funcOp, mlir::Location loc);
136 mlir::FailureOr<cir::FuncOp>
137 resolveCatchCopyThunk(cir::ConstructCatchParamOp op);
138 mlir::LogicalResult lowerFunc(cir::FuncOp funcOp);
140 lowerEhInitiate(cir::EhInitiateOp initiateOp, EhTokenMap &ehTokenMap,
141 SmallVectorImpl<mlir::Operation *> &deadOps);
142 void lowerDispatch(cir::EhDispatchOp dispatch, mlir::Value exnPtr,
144 SmallVectorImpl<mlir::Operation *> &deadOps);
145 mlir::LogicalResult lowerConstructCatchParam(cir::ConstructCatchParamOp op,
147 void lowerInitCatchParam(cir::InitCatchParamOp op);
151mlir::LogicalResult ItaniumEHLowering::run() {
154 voidType = cir::VoidType::get(ctx);
155 voidPtrType = cir::PointerType::get(voidType);
156 auto u8Type = cir::IntType::get(ctx, 8,
false);
157 u8PtrType = cir::PointerType::get(u8Type);
158 u32Type = cir::IntType::get(ctx, 32,
false);
160 for (cir::FuncOp funcOp : mod.getOps<cir::FuncOp>()) {
161 if (mlir::failed(lowerFunc(funcOp)))
162 return mlir::failure();
164 return mlir::success();
169void ItaniumEHLowering::ensureRuntimeDecls(mlir::Location loc) {
172 if (!personalityFunc) {
173 auto s32Type = cir::IntType::get(ctx, 32,
true);
174 auto personalityFuncTy = cir::FuncType::get({}, s32Type,
true);
175 personalityFunc = getOrCreateRuntimeFuncDecl(mod, loc, kGxxPersonality,
179 if (!beginCatchFunc) {
180 auto beginCatchFuncTy =
181 cir::FuncType::get({voidPtrType}, u8PtrType,
false);
182 beginCatchFunc = getOrCreateRuntimeFuncDecl(mod, loc,
"__cxa_begin_catch",
187 auto endCatchFuncTy = cir::FuncType::get({}, voidType,
false);
189 getOrCreateRuntimeFuncDecl(mod, loc,
"__cxa_end_catch", endCatchFuncTy);
192 if (!getExceptionPtrFunc) {
193 auto getExceptionPtrFuncTy =
194 cir::FuncType::get({voidPtrType}, u8PtrType,
false);
195 getExceptionPtrFunc = getOrCreateRuntimeFuncDecl(
196 mod, loc,
"__cxa_get_exception_ptr", getExceptionPtrFuncTy);
209void ItaniumEHLowering::ensureClangCallTerminate(mlir::Location loc) {
210 if (clangCallTerminateFunc)
213 ensureRuntimeDecls(loc);
215 if (
auto existing = mod.lookupSymbol<cir::FuncOp>(
"__clang_call_terminate")) {
216 clangCallTerminateFunc = existing;
220 auto funcTy = cir::FuncType::get({voidPtrType}, voidType,
false);
221 builder.setInsertionPointToEnd(mod.getBody());
223 cir::FuncOp::create(builder, loc,
"__clang_call_terminate", funcTy);
224 funcOp.setLinkage(cir::GlobalLinkageKind::LinkOnceODRLinkage);
225 funcOp.setGlobalVisibility(cir::VisibilityKind::Hidden);
227 mlir::Block *entryBlock = funcOp.addEntryBlock();
228 builder.setInsertionPointToStart(entryBlock);
229 mlir::Value exnArg = entryBlock->getArgument(0);
231 auto catchCall = cir::CallOp::create(
232 builder, loc, mlir::FlatSymbolRefAttr::get(beginCatchFunc), u8PtrType,
233 mlir::ValueRange{exnArg});
234 catchCall.setNothrowAttr(builder.getUnitAttr());
236 auto terminateFuncDecl = getOrCreateRuntimeFuncDecl(
237 mod, loc,
"_ZSt9terminatev",
238 cir::FuncType::get({}, voidType,
false));
239 terminateFuncDecl->setAttr(cir::CIRDialect::getNoReturnAttrName(),
240 builder.getUnitAttr());
241 auto terminateCall = cir::CallOp::create(
242 builder, loc, mlir::FlatSymbolRefAttr::get(terminateFuncDecl), voidType,
244 terminateCall.setNothrowAttr(builder.getUnitAttr());
245 terminateCall->setAttr(cir::CIRDialect::getNoReturnAttrName(),
246 builder.getUnitAttr());
248 cir::UnreachableOp::create(builder, loc);
250 funcOp->setAttr(cir::CIRDialect::getNoReturnAttrName(),
251 builder.getUnitAttr());
252 clangCallTerminateFunc = funcOp;
256mlir::Block *ItaniumEHLowering::buildTerminateBlock(cir::FuncOp funcOp,
257 mlir::Location loc) {
258 assert(clangCallTerminateFunc &&
259 "ensureClangCallTerminate must run before buildTerminateBlock");
260 mlir::Region &body = funcOp.getRegion();
261 mlir::Block *terminateBlock = builder.createBlock(&body, body.end());
262 auto inflight = cir::EhInflightOp::create(
263 builder, loc,
false,
true,
265 auto terminateCall = cir::CallOp::create(
266 builder, loc, mlir::FlatSymbolRefAttr::get(clangCallTerminateFunc),
267 voidType, mlir::ValueRange{inflight.getExceptionPtr()});
268 terminateCall.setNothrowAttr(builder.getUnitAttr());
269 terminateCall->setAttr(cir::CIRDialect::getNoReturnAttrName(),
270 builder.getUnitAttr());
271 cir::UnreachableOp::create(builder, loc);
272 return terminateBlock;
276mlir::LogicalResult ItaniumEHLowering::lowerFunc(cir::FuncOp funcOp) {
277 if (funcOp.isDeclaration())
278 return mlir::success();
284 SmallVector<cir::EhInitiateOp> initiateOps;
285 funcOp.walk([&](cir::EhInitiateOp op) { initiateOps.push_back(op); });
286 if (initiateOps.empty())
287 return mlir::success();
289 ensureRuntimeDecls(funcOp.getLoc());
296 if (!funcOp.getPersonality())
297 funcOp.setPersonality(kGxxPersonality);
304 EhTokenMap ehTokenMap;
305 SmallVector<mlir::Operation *> deadOps;
306 for (cir::EhInitiateOp initiateOp : initiateOps)
307 if (mlir::failed(lowerEhInitiate(initiateOp, ehTokenMap, deadOps)))
308 return mlir::failure();
312 for (mlir::Operation *op : deadOps)
317 for (mlir::Block &block : funcOp.getBody()) {
318 for (
int i = block.getNumArguments() - 1; i >= 0; --i) {
319 if (mlir::isa<cir::EhTokenType>(block.getArgument(i).getType()))
320 block.eraseArgument(i);
327 SmallVector<cir::InitCatchParamOp> initCatchOps;
328 funcOp.walk([&](cir::InitCatchParamOp op) { initCatchOps.push_back(op); });
329 for (cir::InitCatchParamOp op : initCatchOps)
330 lowerInitCatchParam(op);
332 return mlir::success();
361mlir::LogicalResult ItaniumEHLowering::lowerEhInitiate(
362 cir::EhInitiateOp initiateOp, EhTokenMap &ehTokenMap,
363 SmallVectorImpl<mlir::Operation *> &deadOps) {
364 mlir::Value rootToken = initiateOp.getEhToken();
368 builder.setInsertionPoint(initiateOp);
369 auto inflightOp = cir::EhInflightOp::create(
370 builder, initiateOp.getLoc(), initiateOp.getCleanup(),
374 ehTokenMap[rootToken] = {inflightOp.getExceptionPtr(),
375 inflightOp.getTypeId()};
381 SmallVector<mlir::Value> worklist;
382 SmallPtrSet<mlir::Value, 8> visited;
383 worklist.push_back(rootToken);
385 while (!worklist.empty()) {
386 mlir::Value current = worklist.pop_back_val();
387 if (!visited.insert(current).second)
392 SmallVector<mlir::Operation *> users;
393 for (mlir::OpOperand &use : current.getUses())
394 users.push_back(use.getOwner());
398 for (mlir::Operation *user : users) {
404 for (
unsigned s = 0;
s < user->getNumSuccessors(); ++
s) {
405 mlir::Block *succ = user->getSuccessor(
s);
406 for (mlir::BlockArgument arg : succ->getArguments()) {
407 if (!mlir::isa<cir::EhTokenType>(
arg.getType()))
409 if (!ehTokenMap.count(arg)) {
410 mlir::Value ptrArg = succ->addArgument(voidPtrType,
arg.getLoc());
411 mlir::Value u32Arg = succ->addArgument(u32Type,
arg.getLoc());
412 ehTokenMap[
arg] = {ptrArg, u32Arg};
414 worklist.push_back(arg);
418 if (
auto op = mlir::dyn_cast<cir::BeginCleanupOp>(user)) {
421 for (
auto &tokenUsers :
422 llvm::make_early_inc_range(op.getCleanupToken().getUses())) {
424 mlir::dyn_cast<cir::EndCleanupOp>(tokenUsers.getOwner()))
428 }
else if (
auto op = mlir::dyn_cast<cir::BeginCatchOp>(user)) {
431 for (
auto &tokenUsers :
432 llvm::make_early_inc_range(op.getCatchToken().getUses())) {
434 mlir::dyn_cast<cir::EndCatchOp>(tokenUsers.getOwner())) {
435 builder.setInsertionPoint(endOp);
436 cir::CallOp::create(builder, endOp.getLoc(),
437 mlir::FlatSymbolRefAttr::get(endCatchFunc),
438 voidType, mlir::ValueRange{});
443 auto [exnPtr, typeId] = ehTokenMap.lookup(op.getEhToken());
444 builder.setInsertionPoint(op);
445 auto callOp = cir::CallOp::create(
446 builder, op.getLoc(), mlir::FlatSymbolRefAttr::get(beginCatchFunc),
447 u8PtrType, mlir::ValueRange{exnPtr});
448 mlir::Value castResult = callOp.getResult();
449 mlir::Type expectedPtrType = op.getExnPtr().getType();
450 if (castResult.getType() != expectedPtrType)
452 cir::CastOp::create(builder, op.getLoc(), expectedPtrType,
453 cir::CastKind::bitcast, callOp.getResult());
454 op.getExnPtr().replaceAllUsesWith(castResult);
456 }
else if (
auto op = mlir::dyn_cast<cir::ConstructCatchParamOp>(user)) {
457 auto [exnPtr, typeId] = ehTokenMap.lookup(op.getEhToken());
458 if (mlir::failed(lowerConstructCatchParam(op, exnPtr)))
459 return mlir::failure();
460 }
else if (
auto op = mlir::dyn_cast<cir::EhDispatchOp>(user)) {
462 mlir::ArrayAttr catchTypes = op.getCatchTypesAttr();
463 if (catchTypes && catchTypes.size() > 0) {
464 SmallVector<mlir::Attribute> typeSymbols;
465 for (mlir::Attribute attr : catchTypes)
466 typeSymbols.push_back(
467 mlir::cast<cir::GlobalViewAttr>(attr).getSymbol());
468 inflightOp.setCatchTypeListAttr(builder.getArrayAttr(typeSymbols));
470 if (op.getDefaultIsCatchAll())
471 inflightOp.setCatchAllAttr(builder.getUnitAttr());
475 if (!llvm::is_contained(deadOps, op.getOperation())) {
476 auto [exnPtr, typeId] = ehTokenMap.lookup(op.getEhToken());
477 lowerDispatch(op, exnPtr, typeId, deadOps);
479 }
else if (
auto op = mlir::dyn_cast<cir::EhTerminateOp>(user)) {
480 auto [exnPtr, typeId] = ehTokenMap.lookup(op.getEhToken());
481 ensureClangCallTerminate(op.getLoc());
482 builder.setInsertionPoint(op);
483 auto call = cir::CallOp::create(
484 builder, op.getLoc(),
485 mlir::FlatSymbolRefAttr::get(clangCallTerminateFunc), voidType,
486 mlir::ValueRange{exnPtr});
487 call.setNothrowAttr(builder.getUnitAttr());
488 call->setAttr(cir::CIRDialect::getNoReturnAttrName(),
489 builder.getUnitAttr());
490 cir::UnreachableOp::create(builder, op.getLoc());
492 }
else if (
auto op = mlir::dyn_cast<cir::ResumeOp>(user)) {
493 auto [exnPtr, typeId] = ehTokenMap.lookup(op.getEhToken());
494 builder.setInsertionPoint(op);
495 cir::ResumeFlatOp::create(builder, op.getLoc(), exnPtr, typeId);
497 }
else if (
auto op = mlir::dyn_cast<cir::BrOp>(user)) {
499 SmallVector<mlir::Value> newOperands;
500 bool changed =
false;
501 for (mlir::Value operand : op.getDestOperands()) {
502 auto it = ehTokenMap.find(operand);
503 if (it != ehTokenMap.end()) {
504 newOperands.push_back(it->second.first);
505 newOperands.push_back(it->second.second);
508 newOperands.push_back(operand);
512 builder.setInsertionPoint(op);
513 cir::BrOp::create(builder, op.getLoc(), op.getDest(), newOperands);
521 return mlir::success();
527void ItaniumEHLowering::lowerDispatch(
528 cir::EhDispatchOp dispatch, mlir::Value exnPtr, mlir::Value typeId,
529 SmallVectorImpl<mlir::Operation *> &deadOps) {
530 mlir::Location dispLoc = dispatch.getLoc();
531 mlir::Block *defaultDest = dispatch.getDefaultDestination();
532 mlir::ArrayAttr catchTypes = dispatch.getCatchTypesAttr();
533 mlir::SuccessorRange catchDests = dispatch.getCatchDestinations();
534 mlir::Block *dispatchBlock = dispatch->getBlock();
539 if (!catchTypes || catchTypes.empty()) {
541 builder.setInsertionPoint(dispatch);
542 cir::BrOp::create(builder, dispLoc, defaultDest,
543 mlir::ValueRange{exnPtr, typeId});
545 unsigned numCatches = catchTypes.size();
551 mlir::Block *
insertBefore = dispatchBlock->getNextNode();
552 mlir::Block *falseDest = defaultDest;
553 mlir::Block *firstCmpBlock =
nullptr;
554 for (
int i = numCatches - 1; i >= 0; --i) {
555 auto *cmpBlock = builder.createBlock(insertBefore, {voidPtrType, u32Type},
558 mlir::Value cmpExnPtr = cmpBlock->getArgument(0);
559 mlir::Value cmpTypeId = cmpBlock->getArgument(1);
561 auto globalView = mlir::cast<cir::GlobalViewAttr>(catchTypes[i]);
563 cir::EhTypeIdOp::create(builder, dispLoc, globalView.getSymbol());
564 auto cmpOp = cir::CmpOp::create(builder, dispLoc, cir::CmpOpKind::eq,
565 cmpTypeId, ehTypeIdOp.getTypeId());
567 cir::BrCondOp::create(builder, dispLoc, cmpOp, catchDests[i], falseDest,
568 mlir::ValueRange{cmpExnPtr, cmpTypeId},
569 mlir::ValueRange{cmpExnPtr, cmpTypeId});
572 falseDest = cmpBlock;
573 firstCmpBlock = cmpBlock;
577 builder.setInsertionPoint(dispatch);
578 cir::BrOp::create(builder, dispLoc, firstCmpBlock,
579 mlir::ValueRange{exnPtr, typeId});
585 deadOps.push_back(dispatch);
588mlir::FailureOr<cir::FuncOp>
589ItaniumEHLowering::resolveCatchCopyThunk(cir::ConstructCatchParamOp op) {
590 mlir::FlatSymbolRefAttr thunkRef = op.getCopyFnAttr();
591 mlir::StringAttr thunkName = thunkRef.getAttr();
592 auto cached = catchCopyThunks.find(thunkName);
593 if (cached != catchCopyThunks.end())
594 return cached->second;
596 cir::FuncOp thunk = mod.lookupSymbol<cir::FuncOp>(thunkRef);
598 return op.emitError(
"could not resolve catch-copy thunk symbol");
599 assert(thunk->hasAttr(cir::CIRDialect::getCatchCopyThunkAttrName()) &&
600 "verifier should have rejected non-thunk catch-copy reference");
601 if (thunk.isDeclaration())
602 return op.emitError(
"catch-copy thunk has no body to inline");
604 mlir::Region &thunkRegion = thunk.getRegion();
605 if (!llvm::hasSingleElement(thunkRegion))
606 return op.emitError(
"multi-block catch-copy thunks are NYI");
608 mlir::Block &thunkEntry = thunkRegion.front();
609 assert(thunkEntry.getNumArguments() == 2 &&
610 "catch-copy thunk must have exactly two parameters");
611 if (!mlir::isa<cir::ReturnOp>(thunkEntry.getTerminator()))
612 return op.emitError(
"catch-copy thunk must end in cir.return");
614 catchCopyThunks[thunkName] = thunk;
622ItaniumEHLowering::lowerConstructCatchParam(cir::ConstructCatchParamOp op,
623 mlir::Value exnPtr) {
624 if (op.getKind() != cir::InitCatchKind::NonTrivialCopy)
626 "ConstructCatchParam: only non_trivial_copy is supported");
628 mlir::Location loc = op.getLoc();
629 ensureRuntimeDecls(loc);
630 ensureClangCallTerminate(loc);
632 mlir::Value paramAddr = op.getParamAddr();
633 cir::PointerType paramAddrType =
634 mlir::cast<cir::PointerType>(paramAddr.getType());
637 builder.setInsertionPoint(op);
638 cir::CallOp getExnCall = cir::CallOp::create(
639 builder, loc, mlir::FlatSymbolRefAttr::get(getExceptionPtrFunc),
640 u8PtrType, mlir::ValueRange{exnPtr});
641 getExnCall.setNothrowAttr(builder.getUnitAttr());
642 mlir::Value adjusted =
643 cir::CastOp::create(builder, loc, paramAddrType, cir::CastKind::bitcast,
644 getExnCall.getResult());
647 mlir::FailureOr<cir::FuncOp> thunkOr = resolveCatchCopyThunk(op);
648 if (mlir::failed(thunkOr))
649 return mlir::failure();
650 cir::FuncOp thunk = *thunkOr;
654 assert(llvm::hasSingleElement(thunk.getRegion()) &&
655 "multi-block catch-copy thunks are NYI");
658 mlir::Block &thunkEntry = thunk.getRegion().front();
659 mlir::IRMapping mapping;
660 mapping.map(thunkEntry.getArgument(0), paramAddr);
661 mapping.map(thunkEntry.getArgument(1), adjusted);
662 llvm::SmallVector<cir::CallOp> throwingCalls;
663 for (mlir::Operation &thunkOp : thunkEntry.without_terminator()) {
664 mlir::Operation *cloned = builder.clone(thunkOp, mapping);
665 if (cir::CallOp callOp = mlir::dyn_cast<cir::CallOp>(cloned))
666 if (!callOp.getNothrow())
667 throwingCalls.push_back(callOp);
671 if (throwingCalls.empty())
672 return mlir::success();
676 mlir::IRRewriter rewriter(builder);
677 mlir::Block *terminateBlock =
nullptr;
678 for (cir::CallOp call : throwingCalls) {
680 terminateBlock = buildTerminateBlock(call->getParentOfType<cir::FuncOp>(),
684 return mlir::success();
707void ItaniumEHLowering::lowerInitCatchParam(cir::InitCatchParamOp op) {
708 builder.setInsertionPoint(op);
709 mlir::Location loc = op.getLoc();
710 mlir::Value exnPtr = op.getExnPtr();
711 mlir::Value paramAddr = op.getParamAddr();
712 auto paramAddrType = mlir::cast<cir::PointerType>(paramAddr.getType());
713 mlir::Type elementType = paramAddrType.getPointee();
714 cir::InitCatchKind
kind = op.getKind();
717 case InitCatchKind::Reference: {
721 if (
const auto ref = mlir::dyn_cast<cir::PointerType>(elementType)) {
724 if (
auto ptr = mlir::dyn_cast<cir::PointerType>(ref.getPointee()))
725 if (!mlir::isa<cir::RecordType>(ptr.getPointee()))
727 "InitCatchParam: reference of pointer or non-record is NYI");
730 mlir::Value casted = cir::CastOp::create(builder, loc, elementType,
731 cir::CastKind::bitcast, exnPtr);
732 cir::StoreOp::create(builder, loc, casted, paramAddr, {}, {}, {}, {});
735 case InitCatchKind::TrivialCopy: {
736 mlir::Value srcPtr = cir::CastOp::create(builder, loc, paramAddrType,
737 cir::CastKind::bitcast, exnPtr);
738 cir::CopyOp::create(builder, loc, paramAddr, srcPtr, {}, {});
741 case InitCatchKind::NonTrivialCopy:
745 case InitCatchKind::Scalar: {
749 mlir::Value srcPtr = cir::CastOp::create(builder, loc, paramAddrType,
750 cir::CastKind::bitcast, exnPtr);
751 auto loadOp = cir::LoadOp::create(builder, loc, elementType, srcPtr);
752 cir::StoreOp::create(builder, loc, loadOp.getResult(), paramAddr, {}, {},
756 case InitCatchKind::Pointer: {
757 mlir::Value casted = cir::CastOp::create(builder, loc, elementType,
758 cir::CastKind::bitcast, exnPtr);
759 cir::StoreOp::create(builder, loc, casted, paramAddr, {}, {}, {}, {});
762 case InitCatchKind::Objc:
763 llvm_unreachable(
"InitCatchParam: ObjCLifetime is NYI");
774struct CIREHABILoweringPass
775 :
public impl::CIREHABILoweringBase<CIREHABILoweringPass> {
776 CIREHABILoweringPass() =
default;
777 void runOnOperation()
override;
783static void eraseCatchCopyThunks(mlir::ModuleOp mod) {
784 llvm::StringRef catchHelperAttr =
785 cir::CIRDialect::getCatchCopyThunkAttrName();
786 for (cir::FuncOp f : llvm::make_early_inc_range(mod.getOps<cir::FuncOp>())) {
787 if (!f->hasAttr(catchHelperAttr))
791 assert(mlir::SymbolTable::symbolKnownUseEmpty(f, mod) &&
792 "catch-init helper has remaining users");
797void CIREHABILoweringPass::runOnOperation() {
798 auto mod = mlir::cast<mlir::ModuleOp>(getOperation());
803 auto tripleAttr = mlir::dyn_cast_if_present<mlir::StringAttr>(
804 mod->getAttr(cir::CIRDialect::getTripleAttrName()));
806 mod.emitError(
"Module has no target triple");
813 llvm::Triple triple(tripleAttr.getValue());
814 std::unique_ptr<EHABILowering> lowering;
815 if (triple.isWindowsMSVCEnvironment()) {
817 "EH ABI lowering is not yet implemented for the Microsoft ABI");
818 return signalPassFailure();
820 lowering = std::make_unique<ItaniumEHLowering>(mod);
823 if (mlir::failed(lowering->run()))
824 return signalPassFailure();
827 eraseCatchCopyThunks(mod);
833 return std::make_unique<CIREHABILoweringPass>();
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
__device__ __2f16 float __ockl_bool s
mlir::Block * replaceCallWithTryCall(cir::CallOp callOp, mlir::Block *unwindDest, mlir::Location loc, mlir::RewriterBase &rewriter)
Replace a cir::CallOp with a cir::TryCallOp whose unwind destination is unwindDest.
std::unique_ptr< Pass > createCIREHABILoweringPass()
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)