Skip to content

Commit 37643cb

Browse files
committed
use cir::ThrowOp
1 parent a50e4d9 commit 37643cb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2261,14 +2261,12 @@ mlir::Value CIRGenItaniumCXXABI::getCXXDestructorImplicitParam(
22612261

22622262
void CIRGenItaniumCXXABI::emitRethrow(CIRGenFunction &CGF, bool isNoReturn) {
22632263
// void __cxa_rethrow();
2264-
cir::FuncType fTy =
2265-
CGF.getBuilder().getFuncType({}, CGF.getBuilder().getVoidTy());
2266-
2267-
auto fn = CGF.CGM.createRuntimeFunction(fTy, "__cxa_rethrow");
2268-
auto loc = fn.getLoc();
22692264

22702265
if (isNoReturn) {
22712266
auto &builder = CGF.getBuilder();
2267+
assert(CGF.currSrcLoc && "expected source location");
2268+
auto loc = *CGF.currSrcLoc;
2269+
22722270
// The idea here is creating a separate block for the rethrow with an
22732271
// `UnreachableOp` as the terminator. So, we branch from the current block
22742272
// to the rethrow block and create a block for the remaining operations.
@@ -2277,12 +2275,16 @@ void CIRGenItaniumCXXABI::emitRethrow(CIRGenFunction &CGF, bool isNoReturn) {
22772275
auto reg = currentBlock->getParent();
22782276

22792277
if (currentBlock->empty()) {
2280-
builder.createTryCallOp(fn.getLoc(), fn, {});
2278+
builder.create<cir::ThrowOp>(loc, mlir::Value{},
2279+
mlir::FlatSymbolRefAttr{},
2280+
mlir::FlatSymbolRefAttr{});
22812281
builder.create<cir::UnreachableOp>(loc);
22822282
} else {
22832283
auto rethrowBlock = builder.createBlock(reg);
22842284
builder.setInsertionPointToStart(rethrowBlock);
2285-
builder.createTryCallOp(fn.getLoc(), fn, {});
2285+
builder.create<cir::ThrowOp>(loc, mlir::Value{},
2286+
mlir::FlatSymbolRefAttr{},
2287+
mlir::FlatSymbolRefAttr{});
22862288
builder.create<cir::UnreachableOp>(loc);
22872289

22882290
builder.setInsertionPointToEnd(currentBlock);
@@ -2293,7 +2295,7 @@ void CIRGenItaniumCXXABI::emitRethrow(CIRGenFunction &CGF, bool isNoReturn) {
22932295
builder.setInsertionPointToEnd(remBlock);
22942296
// This will be erased during codegen, it acts as a placeholder for the
22952297
// operations to be inserted (if any)
2296-
builder.create<cir::ScopeOp>(fn.getLoc(), /*scopeBuilder=*/
2298+
builder.create<cir::ScopeOp>(loc, /*scopeBuilder=*/
22972299
[&](mlir::OpBuilder &b, mlir::Location loc) {
22982300
b.create<cir::YieldOp>(loc);
22992301
});

0 commit comments

Comments
 (0)