================ @@ -4782,6 +4857,34 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, Function *F = CGM.getIntrinsic(Intrinsic::frameaddress, AllocaInt8PtrTy); return RValue::get(Builder.CreateCall(F, Depth)); } + case Builtin::BI__builtin_stack_address: { + switch (getTarget().getTriple().getArch()) { + case Triple::x86: + return RValue::get(EmitSpecialRegisterBuiltin( + *this, E, Int32Ty, VoidPtrTy, NormalRead, "esp")); + case Triple::x86_64: + return RValue::get(EmitSpecialRegisterBuiltin( + *this, E, Int64Ty, VoidPtrTy, NormalRead, "rsp")); + case Triple::arm: + case Triple::armeb: + case Triple::thumb: + case Triple::thumbeb: + case Triple::aarch64: + case Triple::aarch64_be: + case Triple::aarch64_32: + case Triple::riscv32: + case Triple::riscv64: { + llvm::IntegerType *SPRegIntTy = + getTarget().getTriple().getArchPointerBitWidth() == 64 ? Int64Ty + : Int32Ty; + return RValue::get(EmitSpecialRegisterBuiltin( + *this, E, SPRegIntTy, VoidPtrTy, NormalRead, "sp")); + } + default: + ErrorUnsupported(E, "__builtin_stack_address"); ---------------- aalhwc wrote:
Noted! Thanks! https://github.com/llvm/llvm-project/pull/121332 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits