[clang] [CIR] Attach noreturn attribute to __cxa_bad_cast (PR #198727)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed May 20 08:58:16 PDT 2026


================
@@ -2074,16 +2074,24 @@ static cir::FuncOp getBadCastFn(CIRGenFunction &cgf) {
   // TODO(cir): set the calling convention of the runtime function.
   assert(!cir::MissingFeatures::opFuncCallingConv());
 
+  mlir::NamedAttrList attrs;
+  attrs.set(cir::CIRDialect::getNoReturnAttrName(),
+            mlir::UnitAttr::get(&cgf.cgm.getMLIRContext()));
+
   cir::FuncType fnTy =
       cgf.getBuilder().getFuncType({}, cgf.getBuilder().getVoidTy());
-  return cgf.cgm.createRuntimeFunction(fnTy, "__cxa_bad_cast");
+  return cgf.cgm.createRuntimeFunction(fnTy, "__cxa_bad_cast", attrs);
----------------
andykaylor wrote:

This isn't necessary. Setting the attribute on the call site is sufficient and matches the classic codegen behavior.

https://github.com/llvm/llvm-project/pull/198727


More information about the cfe-commits mailing list