[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 23 17:28:35 PDT 2024


================
@@ -899,6 +899,11 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
   if (CodeGenOpts.PointerAuth.IndirectGotos)
     Fn->addFnAttr("ptrauth-indirect-gotos");
 
+  // Add return control flow integrity attributes for RISCV.
+  if (CodeGenOpts.CFProtectionReturn &&
----------------
efriedma-quic wrote:

We already set a module flag cf-protection-return; why do we need both a module flag and a function flag?

If we do need something RISCV-specific here, can we do it in setTargetAttributes, or something like that?

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


More information about the cfe-commits mailing list