[clang] [CIR] Implement __builtin_return_address and __builtin_frame_address (PR #153698)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 14 15:56:14 PDT 2025


================
@@ -312,6 +312,20 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
   case Builtin::BI__builtin_rotateright64:
     return emitRotate(e, /*isRotateLeft=*/false);
 
+  case Builtin::BI__builtin_return_address:
+  case Builtin::BI__builtin_frame_address: {
+    mlir::Location loc = getLoc(e->getExprLoc());
+    mlir::Attribute levelAttr = ConstantEmitter(*this).emitAbstract(
----------------
andykaylor wrote:

Rather than create an attribute here, which isn't going to be used, could you call `e->getArg(0)->EvaluateKnownConstInt()`?

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


More information about the cfe-commits mailing list