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

Jesse Huang via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 00:39:24 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 &&
----------------
jaidTw wrote:

`cf-protection-return` on RISC-V could be controlled at a per-function granularity (i.e. use function attributes to suppress the instruction generation for some functions), so we still need a function attribute to tag it.
I moved it to `setTargetAttributes` for RISC-V, thanks for the advice.

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


More information about the cfe-commits mailing list