[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:15 PDT 2025


================
@@ -1097,6 +1117,24 @@ mlir::LogicalResult CIRToLLVMCallOpLowering::matchAndRewrite(
                              getTypeConverter(), op.getCalleeAttr());
 }
 
+mlir::LogicalResult CIRToLLVMReturnAddrOpLowering::matchAndRewrite(
+    cir::ReturnAddrOp op, OpAdaptor adaptor,
+    mlir::ConversionPatternRewriter &rewriter) const {
+  auto llvmPtrTy = mlir::LLVM::LLVMPointerType::get(rewriter.getContext());
+  replaceOpWithCallLLVMIntrinsicOp(rewriter, op, "llvm.returnaddress",
----------------
andykaylor wrote:

Given that we're lowering these to an LLVM intrinsic call anyway, I wonder if we should just use `cir.llvm.intrinsic` rather than create dedicated ops for them.

@bcardosolopes Were these useful for some kind of analysis?

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


More information about the cfe-commits mailing list