@@ -2261,14 +2261,12 @@ mlir::Value CIRGenItaniumCXXABI::getCXXDestructorImplicitParam(
2261
2261
2262
2262
void CIRGenItaniumCXXABI::emitRethrow (CIRGenFunction &CGF, bool isNoReturn) {
2263
2263
// 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 ();
2269
2264
2270
2265
if (isNoReturn) {
2271
2266
auto &builder = CGF.getBuilder ();
2267
+ assert (CGF.currSrcLoc && " expected source location" );
2268
+ auto loc = *CGF.currSrcLoc ;
2269
+
2272
2270
// The idea here is creating a separate block for the rethrow with an
2273
2271
// `UnreachableOp` as the terminator. So, we branch from the current block
2274
2272
// to the rethrow block and create a block for the remaining operations.
@@ -2277,12 +2275,16 @@ void CIRGenItaniumCXXABI::emitRethrow(CIRGenFunction &CGF, bool isNoReturn) {
2277
2275
auto reg = currentBlock->getParent ();
2278
2276
2279
2277
if (currentBlock->empty ()) {
2280
- builder.createTryCallOp (fn.getLoc (), fn, {});
2278
+ builder.create <cir::ThrowOp>(loc, mlir::Value{},
2279
+ mlir::FlatSymbolRefAttr{},
2280
+ mlir::FlatSymbolRefAttr{});
2281
2281
builder.create <cir::UnreachableOp>(loc);
2282
2282
} else {
2283
2283
auto rethrowBlock = builder.createBlock (reg);
2284
2284
builder.setInsertionPointToStart (rethrowBlock);
2285
- builder.createTryCallOp (fn.getLoc (), fn, {});
2285
+ builder.create <cir::ThrowOp>(loc, mlir::Value{},
2286
+ mlir::FlatSymbolRefAttr{},
2287
+ mlir::FlatSymbolRefAttr{});
2286
2288
builder.create <cir::UnreachableOp>(loc);
2287
2289
2288
2290
builder.setInsertionPointToEnd (currentBlock);
@@ -2293,7 +2295,7 @@ void CIRGenItaniumCXXABI::emitRethrow(CIRGenFunction &CGF, bool isNoReturn) {
2293
2295
builder.setInsertionPointToEnd (remBlock);
2294
2296
// This will be erased during codegen, it acts as a placeholder for the
2295
2297
// operations to be inserted (if any)
2296
- builder.create <cir::ScopeOp>(fn. getLoc () , /* scopeBuilder=*/
2298
+ builder.create <cir::ScopeOp>(loc , /* scopeBuilder=*/
2297
2299
[&](mlir::OpBuilder &b, mlir::Location loc) {
2298
2300
b.create <cir::YieldOp>(loc);
2299
2301
});
0 commit comments